我从Facebook返回了以下JSON:
{"id":"123456789","email":"darren@darren.com","first_name":"Darren","gender":"male","last_name":"Sweeney","link":"http://www.facebook.com/123456789","locale":"en_GB","name":"Darren Sweeney","timezone":0,"updated_time":"2014-09-26T22:26:59+0000","verified":true}
我正在尝试将其转换为PHP文件进行处理,但从PHP文件中获取NULL
:
JQuery的:
var tmp = JSON.stringify(response);
$.ajax({
type: 'POST',
url: '/ajax/fbLogin.php',
data: {'userData': tmp},
success: function(data) {
console.log(data);
}
});
PHP:
if(isset($_POST['userData'])) {
$json = $_POST['userData'];
var_dump(json_decode($json));
} else {
echo "Error";
}
我出错的任何想法?
答案 0 :(得分:0)
<强> ANSWER 强>
发布答案,因为其他用户可能需要这样做。
正如@nik在评论中指出的那样,Facebook的回复不需要处理,因此,现在可以正常运行:
JQuery的:
$.ajax({
type: 'POST',
url: '/ajax/fbLogin.php',
data: {'userData': response},
success: function(data) {
console.log(data);
}
});
PHP:
if(isset($_POST['userData'])) {
$json = $_POST['userData'];
var_dump($json);
}