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.
kindly reply
Source: Tips4all
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.
ReplyDeleteProvided 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
You could open the Send Dialog in a popup.
ReplyDelete$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/
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.
ReplyDeleteYou can use
ReplyDeleteHTTP POST with
PATH
https://graph.facebook.com/friend_facebook_id/feed
PARAMETER
MESSAGE = your message
ACCESS_TOKEN = your oauth2 access token
fire this event for sending message(initialization of facebook object should be done before).
ReplyDeleteto:user id of facebook
function facebook_send_message(to) {
FB.ui({
app_id:'xxxxxxxx',
method: 'send',
name: "sdfds jj jjjsdj j j ",
link: 'https://apps.facebook.com/xxxxxxxaxsa',
to:to,
description:'sdf sdf sfddsfdd s d fsf s '
});
}
Properties
app_id
Your application's identifier. Required, but automatically specified
by most SDKs.
redirect_uri
The URL to redirect to after the user clicks the Send or Cancel
buttons on the dialog. Required, but automatically specified by most
SDKs.
display
The display mode in which to render the dialog. This is automatically
specified by most SDKs.
to
A user ID or username to which to send the message. Once the dialog
comes up, the user can specify additional users, Facebook groups, and
email addresses to which to send the message. Sending content to a
Facebook group will post it to the group's wall.
link
(required) The link to send in the message.
picture
By default a picture will be taken from the link specified. The URL
of a picture to include in the message. The picture will be shown
next to the link.
name
By default a title will be taken from the link specified. The name of
the link, i.e. the text to display that the user will click on.
description
By default a description will be taken from the link specified.
Descriptive text to show below the link.
$attachment = array(
ReplyDelete'access_token' => $access_token,
'message' => "$msg",
'name' => "$name",
'link' => "$link",
'description' => "$desc",
);
facebook->api('/'.$uesr_id.'/feed', 'POST', $attachment);