Reputation: 310
Acctually I am using that code for getting the facebook post data.
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = 2;
$facebook = new Facebook(array('appId' => 'xxxxxxxxxxx', 'secret' => 'xxxxxxxxxxx....xxxxxxx', 'scope' => 'manage_pages,offline_access,publish_stream,user_photos'));
$result = $facebook->api('/'.$rssfeed_id,'get');
Above code gave some error Like:-
Fatal error: Uncaught OAuthException: (#15) Requires session when calling from a desktop app thrown in C:\Program Files\EasyPHP-5.3.5.0\www\sportsflow\sportsflow_v30\lib\base_facebook.php on line 1271
Please give me any solution for above define problem.
Upvotes: 3
Views: 3166
Reputation: 1738
Had the same issue. You actually don't need user access token, just make sure in your Facebook app settings (under advanced tab) disable the "Native or Desktop app?" setting.
Upvotes: 9
Reputation: 22973
You need a user to connect in order to give him the permissions.
The Facebook()
constructor only takes an app ID and a key:
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxx',
'secret' => 'xxxxxxxxxxx....xxxxxxx'));
The permissions should be added to the LoginUrl:
$loginurl = $facebook->getLoginUrl(array(
'scope' => 'manage_pages,offline_access,publish_stream,user_photos'));
Once the user clicked on the login URL, you can then use the $facebook instance to get the user session:
$user = $facebook->getUser();
If the user indeed exists, you can finally make the API request you want:
$result = $facebook->api('/'.$rssfeed_id, 'get');
Follow this complete example: https://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php
Upvotes: 2