开发者

Publish post with picture and link on event's wall

Is there a way to publish a post with a picture and a link on an event's wall? Currently I can publish only statuses (messages). On the user's wall there is no such issue. I've tried the new Graph API as well as the old REST API ('stream.publish' method) with no success (using PHP SDK). Thank you in advance.

The code I use for Graph 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);

The c开发者_运维问答ode for 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);

As I mentioned above, both is working if I publish on user's wall. On event's wall a status message is published showing only the content of 'message' parameter.


I have the same problem. The event wall post only appears as text message, it is not possible to post a "link" or a "post" to the event wall via any API. The same post appears differently on the users wall or on the event wall. The behavior can be tested here: http://developers.facebook.com/docs/reference/rest/stream.publish/ Just fill out the form and post the same message with a valid attachment once to the users wall and once with a target id (for an event) and see the difference. This behavior is not documented and also google gives not much help. Any workarounds or explanations would be appreciated.

Here is a demo attachment (working on the users wall):

 {     
     "name": "Test name",     
     "href": "http://www.google.com",    
     "description": "Test Desc",     
     "media": [         
            {
                  "type": "image",             
                  "src": "(any image)", 
                  "href": "http://www.google.com"        
            }
              ]

 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜