I am making a very simple gift application on Facebook. The main problem here is how to notify the user which don't use the application about the fact that his friend send him a gift?
As the Notifications are disabled on old REST API and stream.publish
will not work on the friends who didn't authorize to post on their wall, I am confused.
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
}
I use FBML
I can post on the user's friends walls via the PHP API.
Try this :
$facebook->api('/[FRIEND_ID]/feed', 'post', array(
'message' => 'test message',
'link' => 'http://google.com',
'name' => 'test name',
'caption' => 'test caption',
'description' => 'test long description',
));