邀请选定的用户参加 Facebook 活动(通过 Graph API)

发布于 2024-11-27 12:23:41 字数 2145 浏览 0 评论 0原文

在文档、教程和这个论坛的帮助下,我成功地根据登录用户的选择,在他的个人资料或页面上为他创建了一个事件。 我还想,要邀请朋友,我必须使用 events.invite。

由于我不想邀请用户的所有朋友,而是邀请几个朋友,所以我实现了一个请求,结果返回所选朋友的 ID。

我用于 events.invite 通话的那些。我得到 bool 1 结果(这意味着邀请已成功发送),但在好友书签或活动页面中看不到邀请。

除了邀请之外,一切都正常。

出现 3 个问题:

1) events.invite 除了 'create_event' 之外还需要额外的权限吗? 我独立尝试了 events.invite,也无法得到结果...

2)有没有更好的方法在发送邀请之前选择朋友?我不希望每次创建事件时都发送应用程序请求。

3) 如果 2 为负数,如何抑制应用程序请求(和书签)或从朋友的个人资料中删除?通过 API 删除请求显然不会删除应用程序请求中的消息。

主脚本中的 *:[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”中(从请求响应调用):

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"
)); 
}

希望这不是太详细。我将不胜感激任何帮助,因为经过几天的阅读和实验,我终于陷入了这一点。谢谢!

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.

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.

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 questions come up:

1) Does events.invite need additional permission besides 'create_event' ?
I tryed events.invite independently and couldn't get results either...

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) 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.

* 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;
  }

* 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"
)); 
}

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失与倦" 2024-12-04 12:23:42

我认为 GRAPH API 中还没有“发送活动邀请”。它在 REST API 中可用,但它没有按我们的预期工作。
我发现 Facebook 活动存在一些已知问题和限制。请参阅 Facebook 官方文档中的以下链接

可邀请参加活动的人数限制。
http://www.facebook.com/help/? faq=12576#!/help/?faq=202545109787461

活动成员没有收到我发送的消息。
http://www.facebook.com/help/?页=786#!/help/?faq=188295427885002

I don't think "sent event invitation" is in the GRAPH API yet. It is available in REST API but its not working as we expect.
I found some known issues and limitations with facebook events. Please see the links below from the official documentation on facebook

Limitation on number of people that could be invited to an event.
http://www.facebook.com/help/?faq=12576#!/help/?faq=202545109787461

Event members are not receiving messages I have sent.
http://www.facebook.com/help/?page=786#!/help/?faq=188295427885002

意中人 2024-12-04 12:23:41

图表 API 现在允许您通过 user_id 邀请用户。请参阅http://developers.facebook.com/docs/reference/api/event/< /a>

invited

创建

您可以通过向 /EVENT_ID/invited/USER_ID 发出 HTTP POST 来邀请用户参加活动。您可以通过向 /EVENT_ID/invited?users=USER_ID1,USER_ID2,USER_ID3 发出 HTTP POST 来邀请多个用户。这两个都需要 create_event 权限,如果邀请成功则返回 true。

The graph api now allows you to invite users by user_id. See 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文