0

我有一个显示,在使用该应用程序时在 facebook 上显示 6 个随机朋友,但是,我想弄清楚如何更改显示,以便当点击朋友时,他们会收到使用该应用程序的邀请.

什么都没有闪烁,只是某种通知说“鲍勃认为你应该使用这个应用程序”,当点击时,他们会转到应用程序。

不确定它是否有帮助,但这是我必须显示用户朋友的代码。

代码:

<div class= "newboxbottom">
<h1>Why not share?</h1>
<?php
    $user = $facebook->getuser();

if ($user) {
$user_profile = $facebook->api('/me');
$friends = $facebook->api('/me/friends?fields=first_name');

echo '<table>';
foreach (array_slice($friends["data"], 0, 6) as $value) {
    echo '<td>';
    echo '<div class="pic">';
    echo '<img src="https://graph.facebook.com/' . $value["id"] . '/picture?type=normal"/>';
    echo '</div>';
    echo '<div align="center">','<font color="white">','<div class="picName">'.$value["first_name"].'</div>','</font>','</div>';
    echo '</td>';
}
echo '</table>';
}
?>
</div>

非常感谢任何可以提供帮助的人。

4

1 回答 1

1

Try looking into the Notification API that Anvesh mentioned in a comment.

You'll want to be careful with notifications and follow the recommended best practices. You don't want to send notifications to users who would not want them in the first place. You could get hit with negative feedback and get shut down by Facebook.

As for how to actually make the call? I haven't actually used this particular API method, but from what I can gather, you should be able to do something like this:

<?php
  $parameters = array( 
    'href' => ''
    'template' => ''
    'ref' => ''
  );
  try {
    $response = $facebook->api('<enter recipient user facebook id here>/notifications', 'post', $parameters);
  } catch (FacebookAPIException $e) {
    $echo $e->getMessage();
  }

Checkout the documentation on more information on the parameters you need to pass. Hope this helps.

于 2013-05-14T15:02:17.697 回答