イベントのウォールに写真とリンクを含む投稿を公開する方法はありますか? 現在、ステータス (メッセージ) のみを公開できます。ユーザーの壁にはそのような問題はありません。新しい Graph API と古い REST API ('stream.publish' メソッド) を試しましたが、成功しませんでした (PHP SDK を使用)。前もって感謝します。
グラフ API に使用するコード:
$attachment = array(
'message' => 'my message',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'description' => 'this is a description',
'picture' => 'link to an image',
'actions' => array(array('name' => 'See recipe',
'link' => 'http://www.google.com'))
);
$facebook->api('/'.$eventID.'/feed/','post',$attachment);
REST API のコード:
$url = "https://api.facebook.com/method/stream.publish?".$access_token;
$attachment = array('name' => 'This is my demo Facebook application!',
'href' => 'http://news.google.com',
'description' => 'It is fun!',
'media'=> array(array(
'type'=> 'image',
'src' => 'link to an image',
'href' => 'http://www.google.gr'))
);
$params = array();
$params['message'] = "my message";
$params['attachment'] = json_encode($attachment);
$params['target_id'] = $eventID;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$result = curl_exec($ch);
curl_close($ch);
上で述べたように、ユーザーのウォールに公開すると、両方が機能します。イベントのウォールでは、'message' パラメータの内容のみを示すステータス メッセージが発行されます。