How to invite a users friends to an event? Facebook Graph API
I have an application using the Graph API. I have it creating events for the user, but would like to let the user invite their friends from our site 开发者_StackOverflowinstead of having to go to the events Facebook page. Does anyone know of the request I have to send the friends' IDs too to invite them like with the old API? Or if it even exists? I am finding a lot of the finer details in the API documentation are vague. Thank you!
Also, side question, can you send an event photo with the create POST? I see no mention on how to submit a photo with the event creation. Thanks.
I actually was able to get an answer from the Facebook team and they just told me to use the old API through the new PHP interface. They have yet to convert this functionality and don't know if it will be converted.
Edit:
Here is the code I used to invite friends after I got the IDs from the new api ($id_array). This is applied in a wrapper around the PHP Facebook object I used to hold all my Facebook specific code.
$fb = new FacebookGraph(array(
'appId' => 'xxxx',
'secret' => 'xxxx',
'cookie' => true,
));
$fb->api(array(
'method' => 'events.invite',
'eid' => $event_id,
'uids' => $id_array,
'personal_message' => $message,
));
This is actually possible with the Graph API, specifically the invited
connection of the event
's object:
POST /EVENT_ID/invited/USER_ID
Invite a user to an event. Returns true
if the request is successful.
POST /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3
Invite multiple users to an event. Returns true
if the request is successful.
You'll need the create_event
permission. More info is available in this post.
The possibility to invite users to an Event was removed in v2.4 of the Graph API:
The Event node no longer supports GET operations on the endpoints /v2.4/{event_id}/invited, /v2.4/{event_id}/likes, or /v2.4/{event_id}/sharedposts.
There is no way to invite users to an Event anymore, you have to use facebook.com instead.
see Inviting selected users to Facebook-Event (via Graph API)
Facebook now has a graph api for inviting friends to events.
http://developers.facebook.com/docs/reference/api/event/
invited
Create
You can invite users to an event by issuing an HTTP POST to /EVENT_ID/invited/USER_ID. You can invite multiple users by issuing an HTTP POST to /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3. Both of these require the create_event permission and return true if the invite is successful.
And the answer to your side question is here: Attach image to Facebook event (php sdk, rest or graph api)
you can also use javascript sdk:
var inviteCallback = function(result) {
console.log(result);
};
var event_intives = {
method: 'events.invite',
eid: event_id,
uids: friends_list_array,
personal_message: 'custom request message'
};
FB.api(event_intives, inviteCallback);
if all ok, it should log 'true'
精彩评论