json - Facebook Fan Page feed on Website (Age-Protected) -


need in trying posts/wall posts fan page age-gated on facebook show on site.

the fan page age gated let 17 , on view (when logged facebook). but, website behind age gate (locally), want show posts facebook page on site.

i've seen done before, never able @ person's code see how he/she did , can't locate has tried or pulled off.

i've created app on facebook, tied account, able see page on facebook (whether it's age gated or not):

here code

    <?php  function fetchurl($url){   $ch = curl_init();  curl_setopt($ch, curlopt_url, $url);  curl_setopt($ch, curlopt_returntransfer, 1);  curl_setopt($ch, curlopt_timeout, 20);   $feeddata = curl_exec($ch);  curl_close($ch);    return $feeddata;  }  $profile_id = "(page id)";  //app info, needed auth $app_id = "123456789"; $app_secret = "123456789abcdefghij";  $authtoken = fetchurl("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={$app_id}&client_secret={$app_secret}");  $json_object = fetchurl("https://graph.facebook.com/{$profile_id}/posts?{$authtoken}");     $feedarray = json_decode($json_object);  echo $json_object;  foreach ( $feedarray->data $feed_data ) {     echo "<h2>{$feed_data->name}</h2><br />";     echo "{$feed_data->message}<br /><br />"; }    ?> 

the code works pages not have age gate, do, returns invalid (the json cannot process since $authtoken returning nothing).

anyone want me figure out?

most of pages accessed app access token restricted retrieve data public facebook pages, 1 can open without logging in. particular case here, posts want pull, age gated page. facebook requires log-in (if aren't already) can decide show or not page. same documented :

to read page need:

  1. an app or user access token public , non-demographically restricted pages
  2. a user access_token restricted pages current user able view (no special permissions required)

so need utilize user access token access page facebook may allow application access page's posts.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -