开发者

Facebook graph api Friend Invitations

开发者 https://www.devze.com 2023-03-20 11:52 出处:网络
I have managed to send and retrieve data from facebook for invitatin using FB.ui({ method: \'apprequests\',

I have managed to send and retrieve data from facebook for invitatin using

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="+pag开发者_开发问答e_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);

But i want to use single user app request , as per docs i need to use TO: filed but this doesnt work, request is sent as well i get invitation id but php code used above returns false. Am i missing something


you can try direct url example given here https://developers.facebook.com/docs/reference/dialogs/requests/#frictionless_requests

that should work fine from php


This works for me:

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
        });

Moreover you are doing it wrong on PHP side, you would need to redirect the user to a URL where the invitation friend selector would be displayed. There is no way in my knowledge to directly send an invitation to users using PHP.

0

精彩评论

暂无评论...
验证码 换一张
取 消