我在Facebook上製作了一個非常簡單的禮物應用程序。這裏的主要問題是如何通知未使用應用程序的用戶關於他的朋友給他發送禮物的事實?如何通過圖形API在朋友的牆上張貼飼料項目
由於舊REST API上的通知被禁用,並且stream.publish
對於未授權在牆上發佈的朋友無效,所以我很困惑。
if (!empty($_REQUEST["ids"])) {
$friends = (isset($_REQUEST["ids"])) ? $_REQUEST["ids"] : 0;
if (empty($_POST['giftname'])) {
$gname = '1.gif';
} else {
$gname = $this->input->post('giftname');
}
//$this->app_model->send_gift($user, $friends, $gname,$facebook);
//$this->app_model->send_gift($user, $friends, $gname,$facebook);
$to=$friends;
$from=$user;
$gift=$gname;
$total_send=count($friends);
for ($x=0; $x<$total_send; $x++) {
$this->db->query("INSERT INTO gifts (`giftfrom`, `giftto`, `gname`) VALUES($from, $to[$x], \"$gift\")");
try {
// Send notification
//$facebook->api_client->notifications_send($to[$x], 'sent you a gift using <a href="http://apps.facebook.com/tsaxikner/">Հայկական Նվերներ</a>. <a href="http://apps.facebook.com/tsaxikner/">Ստանալ Նվերը</a>.');
// Publish feed story
$feed_body = '<fb:userlink uid="'.$from.'" shownetwork="false"/>-ը նվեր է ուղարկել <fb:name uid="'.$to[$x].'"/>-ին <a href="http://apps.facebook.com/tsaxikner/">Հայկական Նվերներ</a>-ի միջոցով.';
$feed_body = 'Ստուգեք <a href="http://apps.facebook.com/tsaxikner/"> <fb:name uid="'.$to[$x].'" firstnameonly="true" possessive="true"/> Հայկական Նվերներ</a>.';
//$facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body);
$facebook->api_client->make_wall_post($user,$to[$x],$feed_body);
$facebook->api_client->notifications_sendEmail($user, 'You have a gift', $feed_body, $fbml);
//$facebook_graph->api('' $message, null, null, $target_id);
}
catch(Exception $e) {
echo $e->getMessage();
}
}
// end of for
}
我使用FBML
我們現在可以通過php-sdk發送文章到fb-wall。檢查我的答案。 – 2012-02-29 17:41:42