Integrating facebook in php giving invalid signed request with oAuth data

喜你入骨 提交于 2019-12-07 11:58:59

问题


I am trying to integrate facebook php sdk

Following is the code i have tried by reading The facebook tutorial

// init app with app id (APPID) and secret (SECRET)
FacebookSession::setDefaultApplication('APP ID','APP SECRET');

$helper = new FacebookCanvasLoginHelper();
try {
  $session = $helper->getSession();
} catch(FacebookRequestException $ex) {
   echo $ex;   
} catch(\Exception $ex) {
   echo $ex;  
}

However what i get when i open the app on my canvas page as

exception 'Facebook\FacebookSDKException' with message 'Invalid signed request, missing OAuth data.' in /home/thevowaa/public_html/v1/Facebook/FacebookSession.php:267 Stack trace: #0 /home/thevowaa/public_html/v1/Facebook/FacebookSession.php(209): Facebook\FacebookSession::parseSignedRequest('ZM_-jIn_Cm4WHMZ...', NULL) #1 /home/thevowaa/public_html/v1/Facebook/FacebookCanvasLoginHelper.php(60): Facebook\FacebookSession::newSessionFromSignedRequest('ZM_-jIn_Cm4WHMZ...') #2 /home/thevowaa/public_html/v1/index.php(35): Facebook\FacebookCanvasLoginHelper->getSession() #3 {main}

What kind of data am i missing because there is nothing else explained in documentation.


回答1:


I was working with the new facebook sdk and i stumbled upon this website that explains to you how to use the login feature for the SDK. the examples use namespaces so you need at least php 5.4 link to new Facebook SDK tutorial




回答2:


Facebook doc been extremely stupid. They made it hard for devs to test.

You have to Go to developers.facebook.com > Tools > Access Tokens > Grant permission to yourself.

That solved the problem



来源:https://stackoverflow.com/questions/23566644/integrating-facebook-in-php-giving-invalid-signed-request-with-oauth-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!