在这个 PHP 页面上,我正在解析从我正在使用的 facebook 注册插件收到的签名请求。我正在保存的已签名请求 $response 对象的 location 属性存在问题,但我无法弄清楚它是什么。我得到以下两个错误之一: 1.不理解地址,firefox 不知道如何打开地址,因为协议与任何程序无关。当我收到该错误时,浏览器栏会显示:s:18:"New York,New York"; 这是我试图保存到变量中的位置属性的值。第二个错误: 请求的 URL /~spilot/spilot.koding.com/website/New York,New York在这个服务器上没找到。同样,“New York New York”是我试图保存到变量中的 location 属性的值。下面是我的整个 php 页面的代码:
<?php
//code omitted here that decodes and checks the JSON signature of the signed request. It has been tested and I know the problem isn't there.
if ($_REQUEST)
{
$response = parse_signed_request($_REQUEST['signed_request'],
FACEBOOK_SECRET);
}
//this is where I save the values from the registration form into php variables.
$name = $response["registration"]["name"];
$email = $response["registration"]["email"];
$password = $response["registration"]["password"];
$uID = $response["user_id"];
// The problem is with the location variable.
//我希望它作为字符串而不是对象存储到我的数据库中,这就是我使用 //serialize() 的原因,但是无论我是否使用序列化,都会出现上述错误。
$location = $response["registration"]["location"]["name"];
$city = serialize($location);
?>
// I'm using the Parse Cloud Server to power the back end and I have to connect with parse using javascript.
<script type="text/javascript">
var password = '<?php echo $password ?>';
var name = '<?php echo $name ?>';
var uID = '<?php echo $uID ?>';
var email = '<?php echo $email ?>';
var location = '<?php echo $city ?>';
//Initialize the Parse SDK!
Parse.initialize("ivHLAO7z9ml1bBglUNuPSgcWabXe3UeE********","gNeGt04lU7xcew8********qc4POVhBsIBSCVj");
var User = new Parse.User();
User.set("password", password);
User.set("username", name);
User.set("uID", uID);
User.set("email", email);
User.set("location", $city);
User.signUp(null, {
success: function(user)
{
alert("User signed up!");
}
});
</script>