API Facebook:邀请多个用户参加活动
我尝试邀请多个用户参加一个活动。 阅读facebook文档,我发现了这个:
http://developers.facebook.com /docs/reference/api/event/#invited
我编写了以下代码(不起作用):
$facebook = new Facebook(array(
'appId' => '',
'secret' => '',
'cookie' => true,
));
if ($user = $facebook->getUser()) {
$friends = $facebook -> api('/me/friends');
$e_id = ""; //the event id
$friends = $friends['data'];
$e_details = $facebook -> api("/{$e_id}"); //information about the event
for($ids = null,$i = 0,$len = count($friends); $i < $len; $i++) {
$friend = $friends[$i];
$ids .= $friend['id'].',';
}
$data = $facebook -> api("/{$e_id}/invited?users={$ids}", 'POST');
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array('scope' => 'create_event'));
}
我收到以下错误:
未捕获的 OAuthException:(#200) 权限错误抛出< /强>
他说的许可是什么?根据文档,只需要一个权限,这是我设置的。
有人可以指出我的错误吗?任何帮助表示赞赏。提前致谢。
I'm tried invite multiple users to a event.
reading the documentation facebook, I found this:
http://developers.facebook.com/docs/reference/api/event/#invited
I wrote the following code(that does not works):
$facebook = new Facebook(array(
'appId' => '',
'secret' => '',
'cookie' => true,
));
if ($user = $facebook->getUser()) {
$friends = $facebook -> api('/me/friends');
$e_id = ""; //the event id
$friends = $friends['data'];
$e_details = $facebook -> api("/{$e_id}"); //information about the event
for($ids = null,$i = 0,$len = count($friends); $i < $len; $i++) {
$friend = $friends[$i];
$ids .= $friend['id'].',';
}
$data = $facebook -> api("/{$e_id}/invited?users={$ids}", 'POST');
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array('scope' => 'create_event'));
}
I'm getting the fowllowing error:
Uncaught OAuthException: (#200) Permissions error thrown in
what's the permission that he is saying? of according to the documentation only one permission is necessary, which I set.
Can someone point out my error? Any help is appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以首先尝试将 id 存储在一个数组中,不确定尾随的逗号是否弄乱了它。如果您自己在列表中,也将其删除。您还可以在 http://developers.facebook 测试调用.com/tools/explorer/?method=GET&path=me%2Fgroups 查看是否还有其他需要测试的内容。也许添加一个测试来仔细检查用户是否也具有 create_event 权限。
so first try and store the ids in an array not sure if the trailing comma is messing with it. Also remove your self if it is in the list. you can also test the call at http://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fgroups to see if there is anything else to test for. Maybe add a test to double check if the user has the create_event permission as well.
Mauvaise gestion des virgule je pense, là $ids se termine par une virgule, essaye plutôt comme ça :
Et il faut limiter les Invitations à 100 par "boucle" si on croit la FAQ de google sur les nouvelles Limits d'invitations
Mauvaise gestion des virgule je pense, là $ids se termine par une virgule, essaye plutôt comme ça :
Et il faut limiter les invitations à 100 par "boucle" si on croit la FAQ de google sur les nouvelles limitations d'invitations