Hi,

I am able to post from my CMS and share the post directly on the fan page wall.

BUT only when I have signed in to facebook, and have copied the access token from my admin profile, and directy inserted it into the php script that sends the post from the cms to Facebook fan page wall.

So its pretty much useless, as I cant share the post when :

  • Im logged out of facebook
  • The access token has changed (because I had logged out...)

And I am eager to know how I can set the access token to be long lived or never to expire, so that I dont need to go into developeres facebook, graph stuff, and THEN copy the access token and insert into the script in the cms..Not very dynamic..

This below works, when I have copied the access token from the developers site - but how do I get that access token, which changes every time I have logged out.

// Facebook post details :
$access_token = 'LONG NUMBER...';

$page_id        = 'MY_FAN_PAGE_ID';
$status_msg     = 'Message to be posted.... :-)';
//$picture      = 'http://www.mysite.com/img/pic.jpg';
//$link         = 'http://www.mysite.com.dk/';
//$caption      = 'Read the latest news..';
$params         = array('access_token'=>$access_token, 'message'=>$status_msg);
$url            = 'https://graph.facebook.com/MY_FAN_PAGE_ID/feed';
// Curl :
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POSTFIELDS => $params,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_VERBOSE => true
));
$result = curl_exec($ch);
echo '<p style="color:#FFF;">'.$result.'</p>';
// End

I dont currently have an APP, so I am not grapping information from whatever permissions an app could have, related to a fan Page.

Can I get an access token, even if the administration user of the fan page is logged out?? - AND, I need to post to the fan page as the page itself, not as the administrative user of the page

Best regards, Klemme

Member Avatar for LastMitch

I dont currently have an APP, so I am not grapping information from whatever permissions an app could have, related to a fan Page.

You don't need an APP to do that.

Can I get an access token, even if the administration user of the fan page is logged out?? - AND, I need to post to the fan page as the page itself, not as the administrative user of the page

Have you look at this:

http://www.daniweb.com/community-center/geeks-lounge/threads/451027/daniweb-api-developer-competition

and look at the code that a few Daniweb members did and you will get a better understand how to approached the issue you are having.

The issue you are having is not really Facebook related it's more JSON/PHP code related.

Once you correct debug JSON/PHP code then the Facebook API will work.

And if you have free time enter the competition and it wouldn't surpise me that you might win.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.