[英]Can't figure out why I'm getting Server errors from my PHP code
On this PHP page I'm parsing a signed request that I receive from the facebook registration plug in that I'm using. 在此PHP页面上,我正在解析我从使用的Facebook注册插件收到的已签名请求。 There is a problem with the location property from the signed request $response object that I'm saving, but I can't figure out what it is. 我要保存的已签名请求$ response对象中的location属性存在问题,但我无法弄清楚它是什么。 I get one of two errors: 1. The address wasn't understood, firefox doesnt know how to open the address because the protocol (s) isn't associated with any program. 我得到两个错误之一:1 .地址不被理解,firefox不知道如何打开地址,因为协议未与任何程序关联。 When I get that error the browser bar shows this: s:18:"New York,New York"; 当我收到该错误时,浏览器栏显示: s:18:“ New York,New York”; which is the value of the location property that I'm trying to save into a variable. 这是我要保存到变量中的location属性的值。 The second error: The requested URL /~spilot/spilot.koding.com/website/New York,New York was not found on this server. 第二个错误:在此服务器上找不到请求的URL /~spilot/spilot.koding.com/website/New York,New York 。 Again, "New York New York", being the value of the location property that I'm trying to save into a variable. 同样,“ New York New York”是我要保存到变量中的location属性的值。 Below is my code for the entire php page: 下面是我整个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.
//I want it to store to my database as a string and not an object which is why I use //serialize(), but I get the aforementioned errors whether I use serialize or not. //我希望它以字符串而不是对象的形式存储到我的数据库中,这就是为什么我使用// 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>
I'd suggest changing this: 我建议更改此:
var location = '<?php echo $city ?>';
to perhaps 也许
var city = ...
Your error suggests that this being treated as the equivalent of 您的错误提示这被视为等同于
window.location = ...;
which for some reason is coming out of PHP as a serialize()
' string. 由于某种原因,它是从PHP中以serialize()
字符串形式出现的。 Since a serialized string from PHP isn't a valid url, you get that "unknown" protocol error. 由于来自PHP的序列化字符串不是有效的url,因此您会收到“未知”协议错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.