限制申请邀请 - Facebook

发布于 2024-11-09 06:55:33 字数 2061 浏览 0 评论 0原文

我有一个代码,可以自动邀请用户参加我在接受应用程序后创建的活动,但它会自动邀请他们的所有朋友,是否有可能的方法来限制它邀请的朋友数量,而不是每次都邀请他们他们查看应用程序,将其限制为仅最初接受应用程序?

代码:

$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 技术交流群。

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

发布评论

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

评论(1

叫嚣ゝ 2024-11-16 06:55:33

我认为你不能在不违反 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.

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