问题描述
在文档,教程和论坛的帮助下,我设法为他的个人资料或页面上登录的用户创建一个活动,他选择。
我也认为,邀请朋友我必须使用events.invite。
with help of docs, tutorials and this forum I managed to create an event for the logged in user on his profile or page, as he chooses.I also figured, that for inviting friends I'd have to use events.invite.
既然我不想邀请所有的用户的朋友但是几个,我实施了一个请求,结果返回所选的朋友的ID。
Since I don't want to invite all of the user's friends but several, I implemented a request, which as a result returns the selected friend's ids.
我正在用于events.invite调用。我得到了bool 1(这意味着邀请已成功发送),但没有邀请在朋友的书签或事件页面中看到。
Those I'm using for the events.invite call. I get bool 1 as result (which means, the invitation was sent successfully) but there is no invitation to be seen in friends bookmarks or event page.
除邀请之外的所有内容加工。
Everything besides invitation is working.
3个问题出现:
1)除'create_event'外,events.invite是否需要其他权限?
我尝试了独立的event.invite,无法获取结果...
1) Does events.invite need additional permission besides 'create_event' ? I tryed events.invite independently and couldn't get results either...
2)发送邀请之前有没有更好的选择朋友的方法?我不希望每次创建一个事件时发送应用程序请求。
2) Is there a better way to select friends before sending invitation? I do not want app request being sent out each time an event is created.
3)如果2是否定的,应用程序请求(和书签)如何被压制或从朋友的个人资料中删除?通过API删除请求显然不会删除应用程序请求中的消息。
3) If 2 is negative, how can the app request (and bookmark) be subdued or removed from friend's profile? Deleting the request via API obviously doesn't remove the message in application requests.
* 在主脚本中:[javascript]
* in main script: [javascript]
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'Test',
title: 'event invitation for up to 20 friends',
max_recipients: 20,
},
function (response) {
if (response && response.request_ids) {
var requests = response.request_ids.join(',');
var invite_ids = new Ajax.Request('/facebook/handle_invitation.php', {
onSuccess: function(test) { alert('Done!'); },
method: 'post',
parameters: {tid: '<?php echo $target_id; ?>',
request_ids: requests,
eid:'<?php echo $event_id; ?>',
token: '<?php echo $access_token; ?>'}
});
} else {
alert('canceled');
}
});
return false;
}
* 和'handle_invitation.php'从请求响应中调用):
* and in 'handle_invitation.php' (called from request response):
if( isset($_POST['request_ids']) && isset($_POST['uid']) ) {
$target_id = $_POST['tid'];
$event_id = $_POST['eid'];
$access_token = $_POST['token'];
$requests = explode(',',$_POST['request_ids']);
foreach($requests as $request_id) {
$request_data = $fb->api("/$request_id?$access_token");
$invite_id[] = $request_data['to']['id'];
$fb->api("/$request_id?$access_token", "DELETE");
}
//invite friends to my event
$return = $fb->api(array(
'method' => 'events.invite',
'eid' => $event_id,
'uids' => $invite_id,
'personal_message' =>"Einladung zu meinem Event"
));
}
希望这不太详细。我会感谢任何帮助,因为经过几天的阅读和实验,我终于坚持在这一点上。 Thx!
Hope this was not too detailed. I'd appreciate any help, since after days of reading and experimenting I'm finally stuck at this point. Thx!
推荐答案
图api现在允许您通过user_id邀请用户。请参阅
The graph api now allows you to invite users by user_id. See http://developers.facebook.com/docs/reference/api/event/
邀请
创建
您可以通过向/ EVENT_ID / invite / USER_ID发出HTTP POST来邀请用户进行事件。您可以通过向/ EVENT_ID / invite发送HTTP POST来邀请多个用户?users = USER_ID1,USER_ID2,USER_ID3。这两个都需要create_event权限,如果邀请成功,则返回true。
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.
这篇关于邀请所选用户进入Facebook-Event(通过Graph API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!