how send message facebook friend through graph api using Accessstoken

不问归期 提交于 2019-11-26 08:55:09

问题


Can anyone help me to send message to facebook friends using graph api.

I tried

$response = $facebook->call_api(\"/me/feed\", \"post\", \"to=john\",\"message=You have a Test message\");

It\'s not working. I have the accesstoken of the user in my hand.only I am confused on sending process.


回答1:


You can't send messages using a Facebook application. You used to be able to do that, but the (predictable?) colossal amount of abuse led to the revocation of this ability.

Provided Alice, your user, has given you the necessary extended permissions, you have the following options:

  • Post to Alice's wall on her behalf
  • Send email to Alice
  • Create events on behalf of Alice
    • invite Bob (not your user) to said events
  • Issue a request/invitation on behalf of Alice to Bob
  • Issue a request from the App to Alice



回答2:


You could open the Send Dialog in a popup.

 $parameters = array(
    'app_id' => $facebook->getAppId(),
    'to' => $facebookUserId,
    'link' => 'http://google.nl/',
    'redirect_uri' => 'http://my.app.url/callback'
 );
 $url = 'http://www.facebook.com/dialog/send?'.http_build_query($parameters);
 echo '<script type="text/javascript">window.open('.json_encode($url).', ...

For detailed options see: https://developers.facebook.com/docs/reference/dialogs/send/




回答3:


$attachment =  array(

    'access_token' => $access_token,
    'message' => "$msg",
    'name' => "$name",
    'link' => "$link",
    'description' => "$desc",
);

facebook->api('/'.$uesr_id.'/feed', 'POST', $attachment);



回答4:


Technically you can do feed or cross feed post with privacy settings that allows only the feed owner to see the post but its not really sending a message to a person.




回答5:


You can use
HTTP POST with
PATH
https://graph.facebook.com/friend_facebook_id/feed
PARAMETER
MESSAGE = your message
ACCESS_TOKEN = your oauth2 access token



回答6:


You can send to their facebook email. Facebook email is consisting profile nickname+'@facebook.com'. The email will goes to their facebook inbox message. Note that facebook email does not accept spoofing email. You will need whitelabel domain or use SendGrid.




回答7:


You will need to integrate xmpp chat to reply a message and to write a new message.




回答8:


I saw this post and noticed it was not right. Using the javascriot api you can post to a friend's feed like so: In this example "friendID" is the FB user ID of the friend. This api call requires the "publish_stream" permission.

FB.api('/'+friendID+'/feed', 'post', 
            {
                method: 'feed',
                message: messageText,
                name: 'write a title here',
                caption: 'Put a caption here.',
                description: 'Put your description here.',
                link: 'http://stackoverflow.com/questions/2943297/how-send-message-facebook-friend-through-graph-api-using-accessstoken',
                picture: 'link to the preview thumbnail',                   
            },
             function(response) {
              if (!response || response.error) {
                //alert('Error occured');
              } else {
                //alert('Post ID: ' + response.id);
              }
        });

So this does it with the javasfcript SDK- the PHP method must be similar.




回答9:


Instead of using the below code

    [facebook dialog:@"feed"
     andParams:params 
     andDelegate:self]; 

Use the following solution

[facebook requestWithGraphPath:@"me/feed"
   andParams:params
   andHttpMethod:@"POST"
   andDelegate:self];



回答10:


It seems like you want to send the message right into the receiver's primary inbox, there isn't any graph api for this, you need to use facebook xmpp chat api and send the message, however I have made a php class which is too easy to use, just some function calls and call to a send message function and message will be sent, its open source, check it out: facebook message api php the description says its a closed source but the comment says its a open source now, you can clone from github. It's a open source now.



来源:https://stackoverflow.com/questions/2943297/how-send-message-facebook-friend-through-graph-api-using-accessstoken

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!