Facebook PHP Api cUrl auto post to page's wall (not profile wall)

Posted by Ian on Stack Overflow See other posts from Stack Overflow or by Ian
Published on 2010-09-28T11:43:04Z Indexed on 2012/10/02 3:38 UTC
Read the original article Hit count: 256

Filed under:
|

I need to be able to post to the wall of my page, i have given offline_permissions and I got it to post to my profile wall but I need it to post to my pages wall.

Anyone know how to do this, where does my code need changing? thanks

<?php session_start();

$fb_page_id = 106502962712016;
$fb_access_token = '121247121254761|588e45312b074a0ec3dd62c39-1727154049|L0VGSJsCBrsSj5H4w1LwobRGeRc';

$url = 'https://graph.facebook.com/'.$fb_page_id.'/feed';

$attachment =  array(
'access_token' => $fb_access_token,
'message' => 'message text',
'name' => 'name text',
'link' => 'http://domain.com/',
'description' => 'Description Text',
'picture'=>'http://domain.com/logo.jpg',
 );

 // set the target url
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL,$url);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
 curl_setopt($ch, CURLOPT_HEADER,0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
 $go = curl_exec($ch);

 curl_close ($ch);

?>

© Stack Overflow or respective owner

Related posts about php

Related posts about facebook