Display public facebook posts on your website

Display public facebook posts on your website

//

A straightforward way to get your facebook public posts onto another website without requiring your guests to have a facebook account.

  1. Log into the facebook account you want to display the posts of
  2. Go to https://developers.facebook.com/apps, it will ask you for your password again
  3. On the top right of the next screen, click on the button “+Create New App”
  4. In the first field on the form enter an “App Name” and click “Continue”. You do not need to enter anything for the other 2 fields. You may then be asked to enter the captcha validation text.
  5.  On the next screen you will see values for “App ID:” and “APP Secret:”, you will use these in your code when you make a request.
  6.  Click “Save Changes”
  7. To make the request and get facebook posts add the following lines to your PHP code:

 

//Request to facebook to obtain an access token. Replace the Xs so client_id's Xs is the value from “App ID” and client_secret's Xs is “App Secret”

$access_str = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id=XXXXXX&client_secret=XXXXXX&grant_type=client_credentials');

parse_str($access_str);

//Request the public posts. Replace "YOUR-PROFILE-NAME" with your profile name.

$json_str = file_get_contents('https://graph.facebook.com/YOUR-PROFILE-NAME/feed?access_token='.$access_token);

//decode json string into array

$data = json_decode($json_str);

//Now iterate through $data to get the information you want to display.

Need Expert Help?

See Our Full Menu of Data Services

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!