限制申请邀请 - Facebook
我有一个代码,可以自动邀请用户参加我在接受应用程序后创建的活动,但它会自动邀请他们的所有朋友,是否有可能的方法来限制它邀请的朋友数量,而不是每次都邀请他们他们查看应用程序,将其限制为仅最初接受应用程序?
代码:
$bsize = 400;
require_once('settings.php');
$_SESSION['init'] = true;
$current_date=date('m/d/Y');
$facebook = new Facebook(array(
'appId' => $settings['appid'],
'secret' => $settings['secret'],
'cookie' => true,
));
//Facebook Authentication part
$session = $facebook->getSession();
$appurl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'uid' => $uid,
'req_perms' => 'create_event,rsvp_event'
)
);
$fbme = null;
if (!$session) {
echo "<script type='text/javascript'>top.location.href = '$appurl';</script>";
exit;
} else {
try {
$uid = $facebook->getUser();
$fbme = $facebook->api('/me?fields=id');
} catch (FacebookApiException $e) {
echo "<script type='text/javascript'>top.location.href = '$appurl';</script>";
exit;
}
}
$rsvpResult = $facebook->api('/'.$eventid.'/attending','POST', array() );
$friendIDs = array();
try {
$result = $facebook->api('/me/friends?fields=id');
foreach ($result['data'] as $friend) {
$friendIDs[] = $friend['id'];
}
} catch(Exception $o) {
echo $o."ERROR: Friends do not allow invitations!";
}
$eid = "$eventid";
$facebook->setFileUploadSupport(false);
$eventInviteParam = array(
'method' => 'events.invite',
'eid' => $eid,
'personal_message'=> 'Check this out',
'access_token' => $session['access_token']
);
if( count($friendIDs) > 0 ){
$i =0;
$friendIDPartialList = array_chunk($friendIDs, $bsize);
// echo "list count :".count($friendIDPartialList);
foreach($friendIDPartialList as $flist){
$eventInviteParam['uids'] = $flist;
try {
$result = $facebook->api($eventInviteParam);
} catch(Exception $o) { echo $o; }
}
}
I have a code that auto invites users to an event that I create upon their acceptance of the application, but it auto invites all their friends, is there a possible way to limit the amount of friends it invites, and instead of inviting them every time they view the app, limit it to just the initial acceptance of the application?
Code:
$bsize = 400;
require_once('settings.php');
$_SESSION['init'] = true;
$current_date=date('m/d/Y');
$facebook = new Facebook(array(
'appId' => $settings['appid'],
'secret' => $settings['secret'],
'cookie' => true,
));
//Facebook Authentication part
$session = $facebook->getSession();
$appurl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'uid' => $uid,
'req_perms' => 'create_event,rsvp_event'
)
);
$fbme = null;
if (!$session) {
echo "<script type='text/javascript'>top.location.href = '$appurl';</script>";
exit;
} else {
try {
$uid = $facebook->getUser();
$fbme = $facebook->api('/me?fields=id');
} catch (FacebookApiException $e) {
echo "<script type='text/javascript'>top.location.href = '$appurl';</script>";
exit;
}
}
$rsvpResult = $facebook->api('/'.$eventid.'/attending','POST', array() );
$friendIDs = array();
try {
$result = $facebook->api('/me/friends?fields=id');
foreach ($result['data'] as $friend) {
$friendIDs[] = $friend['id'];
}
} catch(Exception $o) {
echo $o."ERROR: Friends do not allow invitations!";
}
$eid = "$eventid";
$facebook->setFileUploadSupport(false);
$eventInviteParam = array(
'method' => 'events.invite',
'eid' => $eid,
'personal_message'=> 'Check this out',
'access_token' => $session['access_token']
);
if( count($friendIDs) > 0 ){
$i =0;
$friendIDPartialList = array_chunk($friendIDs, $bsize);
// echo "list count :".count($friendIDPartialList);
foreach($friendIDPartialList as $flist){
$eventInviteParam['uids'] = $flist;
try {
$result = $facebook->api($eventInviteParam);
} catch(Exception $o) { echo $o; }
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你不能在不违反 Facebook 政策的情况下自动邀请用户的朋友:
http://developers.facebook.com/policy/
让用户通过明确标记的方式主动发出邀请按钮,就可以了。
I don't think you can autoinvite the user's friends without violating Facebook's policy:
http://developers.facebook.com/policy/
Let the user actively issue invitations through a clearly labled button, and you'll be OK.