Facebook图形api朋友邀请

时间:2011-07-14 11:35:01

标签: php facebook facebook-graph-api

我已设法使用

从facebook发送和检索来自invitatin的数据
FB.ui({
            method: 'apprequests',
            to: sendto,
            message: 'Win Mega Prizes!',
            title: 'Enter in this contest!'
        },
        function (response) {   
           if (response && response.request_ids) {
               var requests = response.request_ids.join(',');
               alert(requests);
                    window.location.href = "http://www.rmyserver/index.php?invitations="+requests+"&contest_id="+c_id+"&page_id="+page_id+"&user="+from+"&g_id="+g_id+"&sendto="+sendto+"&single=1";         

            } else {
                alert('canceled');
            }

PHP

foreach($requests as $request_id) {
        // Get the request details using Graph API
       echo $request_content = json_decode(file_get_contents("https://graph.facebook.com/$request_id?$app_token"), TRUE);

但我想使用单用户应用程序请求,根据文档,我需要使用TO:提交,但这不起作用,请求也发送,我得到邀请ID但上面使用的PHP代码返回false。 我错过了什么

2 个答案:

答案 0 :(得分:0)

你可以尝试直接在这里给出的网址示例https://developers.facebook.com/docs/reference/dialogs/requests/#frictionless_requests

应该可以正常使用php

答案 1 :(得分:-1)

这对我有用:

FB.ui({
            method:'apprequests',
            message:'I want you to open up your heart a little.',
            to:123456798,
            // filters:['app_non_users'], // commented: let users send notifications to app users too, probably a good idea to make them revisit?
            data:'' // send data what you would like to track, FB will send that back in the URL for us
            // @todo send google campaign parameters
        });

此外,您在PHP方面做错了,您需要将用户重定向到将显示邀请朋友选择器的URL。据我所知,我无法直接向使用PHP的用户发送邀请。