I have a problem using the facebook-ignited package.
Webserver: MAMP + OSX 10.6.7 / PHP: 5.2.13 ( access via "local domain" [etc/hosts - local.mydomain.de, virtual host in MAMP/apache] )
Codeigniter Reactor: 2.0.2 CIBonfire: 1.0.1 Facebook-Ignited: 1.0.4
config/fb_ignited.php:
$config['fb_appid'] = 'XXXXXX6';
$config['fb_secret'] = 'XXXXXX';
$config['fb_cookie'] = true;
$config['fb_canvas'] = '';
$config['fb_auth'] = '';[/code]
controller:
class welcomeFacebook extends Front_Controller{
function getMe(){
// The fb_ignited library is already auto-loaded so call the user and app.
$this->load->library('fb_ignited');
$this->fb_me = $this->fb_ignited->fb_get_me(false);
if (isset($this->request_result)){
$content_data['error'] = $this->request_result;
}
$content_data['me'] = $this->fb_me;
$content_data['fb_app'] = $this->fb_app;
$this->load->view('welcome_message_fbignited', $content_data); // the default facebook_ignited view template
}
}
The result is an infinite Loop with Chrome and Safari, both when logged in at facebook already or not...
oauth (www.facebook/com/dialog) 302 Found
uiserver.php (www.facebook.com/connect) 302 Found
/welcomeFacebook/getMe/?code=[….开发者_如何学Go]&state=[….]
oauth (www.facebook/com/dialog) 302 Found
...
fb_get_me() (Fb_ignited) fails permanently, because $this->CI->facebook->getUser() does not return a user, so it redirects over and over again. I figured out, that there is no signed request. And that getUserFromAvailableData() (base_facebook.php) fails to get user data.
The app-id and app_secret are fine, because i tested it with the javascript-sdk and it all worked well.
How can i debug this? Is there a debug option for php-sdk / facebook-ignited? Or is it a codeigniter-cookie/session related problem? (Or is it something else? ;))
Thanks in advance for your help!
Matthias
PS: 3380417 did not help.
The problem was caused because of the clean urls (without index.php) with htaccess:
RewriteRule ^(.*)$ /index.php?/$1 [L]
I have 2 solutions now:
config.php - enable query strings
| Please note that some of the helpers won't work as expected when
| this feature is enabled, since CodeIgniter is designed primarily to
| use segment based URLs.
$config['enable_query_strings'] = TRUE;
Or if you don’t want to enable it global, paste this to your constructor or method:
parse_str($_SERVER['QUERY_STRING'],$getArr);
$_REQUEST['state']=$getArr['state'];
$_REQUEST['code']=$getArr['code'];
I do not know if this causes some security issues…
I'm using CodeIgniter 2.2.0 and Facebook PHP SDK 3.2.3.
The first solution proposed by Programmieraffe didn't work for me since I'm relying on many libraries that require CI's clean URLs.
However, the second one worked by simply patching the constructor of the BaseFacebook class in this way:
public function __construct($config) {
// patched to work with CodeIgniter's clean URLs
parse_str($_SERVER['QUERY_STRING'],$request);
$_REQUEST = $request;
$this->setAppId($config['appId']);
$this->setAppSecret($config['secret']);
if (isset($config['fileUpload'])) {
$this->setFileUploadSupport($config['fileUpload']);
}
if (isset($config['trustForwarded']) && $config['trustForwarded']) {
$this->trustForwarded = true;
}
if (isset($config['allowSignedRequest'])
&& !$config['allowSignedRequest']) {
$this->allowSignedRequest = false;
}
$state = $this->getPersistentData('state');
if (!empty($state)) {
$this->state = $state;
}
}
Since Facebook SDK expects the signed request to be read from the query string and CodeIgniter disables it, reading it entirely and overwriting the whole $_REQUEST variable, will do the job. This way the SDK will still read from $_REQUEST without noticing any action perform by CI.
Hope it helps :)
精彩评论