简体   繁体   中英

Issue related to Facebook Graph API

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM