Facebook的API 400错误的请求 [英] Facebook API 400 Bad Request
问题描述
我试图使用Facebook的API来运行FQL查询。我在PHP中设置好一切这里是code的外观:
I'm trying to use the Facebook api to run an fql query. I set everything up in PHP here is how the code looks:
$app_id = 'APP_ID';
$app_secret = 'APP_secret';
$my_url = "url.com/facebook.php";
$code = $_REQUEST["code"];
//auth user
if(empty($code)) {
$dialog_url = 'https://www.facebook.com/dialog/oauth?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url) ;
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}
//get user access_token
$token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
. $app_id . '&redirect_uri=' . urlencode($my_url)
. '&client_secret=' . $app_secret
. '&code=' . $code;
$access_token = file_get_contents($token_url);
// Run fql query
$fql_query_url = 'FQL_Query';
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);
一切正常使用上述code,但最近我决定改变我的URL结构,而不是通过访问网页的 url.com/facebook.php 我想访问通过 url.com/#facebook 。
当我做了这个更改为$ my_url变量我收到以下错误。
When I made this change to the $my_url variable I received the following errors.
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
任何想法?谢谢!
Any ideas? Thanks!
推荐答案
我解决它在XAMPP加入扩展= php_openssl.dll
在 XAMPP /php/php.ini
文件。
在XAMPP的某些版本中此行被注释掉像;延长= php_openssl.dll
,
所以只是注释,并重新启动Apache。
I solved it in XAMPP by adding extension=php_openssl.dll
in xampp/php/php.ini
file.
in some versions of XAMPP this line is commented like ;extension=php_openssl.dll
,
so just uncomment it and restart apache.
这篇关于Facebook的API 400错误的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!