进一步的Facebook登录Javascript错误 [英] Further Facebook Login Javascript Errors
问题描述
<?php
再次,我的应用程序ID正确显示在错误代码中。
define('YOUR_APP_ID','** APP ID **');
define('YOUR_APP_SECRET','** SECRET ID **');
函数get_facebook_cookie($ app_id,$ app_secret){
$ args = array();
parse_str($ _ COOKIE ['fbs_'。$ app_id],'\\''),$ args);
ksort($ args);
$ payload = ';
foreach($ args as $ key => $ value){
if($ key!='sig'){
$ payload。= $ key。'='。 $ value;
}
}
if(md5($ payload。$ app_secret)!= $ args ['sig']){
return null;
}
return $ args;
}
$ cookie = get_facebook_cookie(YOUR_APP_ID,YOUR_APP_SECRET);
$ user = json_decode(file_get_contents(
'https://graph.facebook.com/me?access_token='
$ cookie ['access_token']));
?>
注意:未定义的索引:fbs _ ** MY C中的APP ID **:\wamp\www\_header.php第10行
注意:未定义的索引:sig在C:\wamp在线18上的\\www\_header.php
是否可能是与WAMP相关的问题?感谢提前。
解决方案检查你的括号。很多时候,支架层次结构之间的简单混淆可以解决这些令人讨厌的错误。
This is kinda an extension of my previous question. With that somewhat resolved, I'm still encountering errors. I'm working off of the Javascript guide here. I'm now on the last code segment of the page, towards the bottom. At the top of my page, I have the following code (APP ID and SECRET ID are defined in my code):
<?php define('YOUR_APP_ID', '**APP ID**'); define('YOUR_APP_SECRET', '**SECRET ID**'); function get_facebook_cookie($app_id, $app_secret) { $args = array(); parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args); ksort($args); $payload = ''; foreach ($args as $key => $value) { if ($key != 'sig') { $payload .= $key . '=' . $value; } } if (md5($payload . $app_secret) != $args['sig']) { return null; } return $args; } $cookie = get_facebook_cookie(YOUR_APP_ID, YOUR_APP_SECRET); $user = json_decode(file_get_contents( 'https://graph.facebook.com/me?access_token=' . $cookie['access_token'])); ?>
But now I get these errors (googling them hasn't turned anything useful up):
Again, my app id IS shown in the error code correctly.
Notice: Undefined index: fbs_**MY APP ID** in C:\wamp\www\_header.php on line 10 Notice: Undefined index: sig in C:\wamp\www\_header.php on line 18
Is it possible it could be a problem associated with WAMP? Thanks in advance.
解决方案Check your brackets. A lot of times simple confusion among bracket hierarchies can fix these obnoxious errors.
这篇关于进一步的Facebook登录Javascript错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!