All posts in News

Facebook Graph posts data now requires access_token

Based on the Facebook Developer Love blog post here, anything from https://graph.facebook.com/[id]/posts will now require a valid access_token to view. Why they chose to implement this on public Facebook Page data we’ll never know.

Anyway, here is a workaround that will get you a valid access_token without the need to log your site visitors in to Facebook first. Useful if you followed my Web Designer tutorial I wrote about using Facebook pages to drive your news on your website and now are getting a load of errors.

So the first thing to do is go to https://www.facebook.com/developers and set up a new Facebook application. Once you have done that, go into the “Web Site” section and fill in your website details…

Facebook Developer screenshot

Facebook Developer screenshot

You will also notice on that page that you have been assigned an Application ID and Application Secret, make a note of these, and do what the name suggests and keep the Application Secret, a secret (hence why mine is blurred above)

Now jump over to your PHP code and add the following in…

$FBid = 'REPLACE_WITH_PAGE_ID_OR_NAME (eg. "terrorfall")';

$app_id = 'REPLACE_WITH_APPLICATION_ID';
$app_secret = "REPLACE_WITH_APPLICATION_SECRET";

Now you can make a call to a Facebook URL which will issue you an access token, do this like so…


$FBid = 'REPLACE_WITH_PAGE_ID_OR_NAME (eg. "terrorfall")';

$app_id = 'REPLACE_WITH_APPLICATION_ID';
$app_secret = "REPLACE_WITH_APPLICATION_SECRET";

$access_token = file_get_contents("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=".$app_id."&client_secret=".$app_secret);

Now you have an access token, you can make the same graph call and get your page data…


$FBid = 'REPLACE_WITH_PAGE_ID_OR_NAME (eg. "terrorfall")';

$app_id = 'REPLACE_WITH_APPLICATION_ID';
$app_secret = "REPLACE_WITH_APPLICATION_SECRET";

$access_token = file_get_contents("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=".$app_id."&client_secret=".$app_secret);

$FBpage = file_get_contents("https://graph.facebook.com/".$FBid."/posts?".$access_token);

$FBdata = json_decode($FBpage);

Now you can create a loop as before and output all your authenticated Facebook data.

Pete

Issue 181 of Web Designer Magazine

It’s here! Issue 181 of Web Designer magazine goes on sale today!

Turn to page 66 to see Pete’s tutorial on how to use Facebook to drive your sites news section.

If you have any questions about the article, please do not hesitate to get in touch via the Contact Us page.



Pete speaking at the Social Media World Forum

On March 29th, Pete will be speaking at the Social Media World Forum as a guest of SocialTalk on behalf of EA. Discussing how EA uses SocialTalk as part of their social strategy. For more information on this event and to buy tickets, visit http://www.socialmedia-forum.com/europe/

Updates to the SocialTracker

Just finished updating the EA SocialTracker, a tool that allows to track daily, weekly and monthly changes in social activity across Facebook, Twitter and YouTube. Results are presented in a sortable table and graphically using the Google Graphs API.

Terror Designs in Web Designer magazine

Be sure to keep an eye out in the March edition of Web Designer magazine, for an article written by Pete Simmons of Terror Designs.

Pete will be teaching you how to use your existing Facebook page as a content management system for your website. All news items that you put into your page will be displayed in full on your site, complete with any embedded media.

Brand new website

Hi! Welcome to the new website of Terror Designs Limited, feel free to browse our portfolio. If you have any questions, please do not hesitate to get in touch via the Contact Us page