how send message facebook friend through graph api using Accessstoken
Solution 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
Solution 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/
Solution 3
$attachment = array(
'access_token' => $access_token,
'message' => $msg,
'name' => $name,
'link' => $link,
'description' => $desc,
);
facebook->api('/'.$uesr_id.'/feed', 'POST', $attachment);
Solution 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.
Solution 5
You will need to integrate xmpp chat to reply a message and to write a new message.
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
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.
-
qasimzee over 12 yearsThanks a lot bob. I was exactly looking for this. This even helps in pre-populating message fields so it's so easy to send an invitation link to my app using this dialog.
-
Somnath Muluk about 12 yearsThis will post message on $uesr_id's wall.
-
Michael Mior about 12 yearsNote that you can't send email to Bob from Alice (a message from Alice to Bob appears to be the OP's goal)
-
Julio Santos about 12 yearsWell... one could play with the
to
field ;) But no, you can't. Hence it not being listed. -
CyberJunkie almost 12 yearsIs there a way to bypass the send dialog popup and send the message directly via url?
-
lomse about 11 years@SomnathMuluk This does not work anymore cause it is deprecated!
-
Somnath Muluk about 11 years@Lomse: Yes... It's deprecated on Feb 2013.
-
John Erck almost 11 yearsHere's the link saying you can't get friends' email addresses: developers.facebook.com/docs/reference/login/email-permissions
-
tusharmath over 10 yearslinks to documentation please?
-
Sajuna Fernando over 10 yearsI know this was answered sometime back. But how do i get my hands on a white label domain? Do you know which criteria fb uses to determine spoofing?
-
Rajat Gupta over 10 yearscould you have multiple userIds specified by app in the
to
field ? -
user1349663 almost 10 yearsThis didn't work for me :( Unfortunate, considering how easy it is
-
sulaiman sudirman almost 10 yearsFacebook has discontinued this since last February, it will forward to your real email instead. forbes.com/sites/kashmirhill/2014/02/25/…
-
lephleg over 6 years'Issue a request/invitation on behalf of Alice to Bob' how can someone do this from backend?