Quantcast
Viewing latest article 9
Browse Latest Browse All 10

Facebook Fan Page feed on Website (Age-Protected)

Need help in trying to get posts/wall posts from a fan page that is age-gated on facebook to show up on my site.

the fan page is age gated to only let those 17 and over to view it (when they are logged into facebook). But, my website is behind an age gate (locally), so I want to show the posts from that facebook page on my site.

I've seen it done before, but I was never able to look at the person's code to see how he/she did it and I can't locate anyone who has tried or successfully pulled it off.

I've created an app on facebook, tied to my account, that is able to see any page on facebook (whether it's age gated or not):

Here is my 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 for 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 as $feed_data )
{
    echo "<h2>{$feed_data->name}</h2><br />";
    echo "{$feed_data->message}<br /><br />";
}

  ?>

The code works for pages that do not have an age gate, but those that do, it returns as invalid (the JSON cannot process anything since the $authToken is returning nothing).

anyone want to help me figure this out?


Viewing latest article 9
Browse Latest Browse All 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>