![](/img/trans.png)
[英]I'm getting what seems to be an infinite loop and can't figure out why - PHP/WordPress
[英]Can't figure out why I'm getting Server errors from my PHP code
在此PHP頁面上,我正在解析我從使用的Facebook注冊插件收到的已簽名請求。 我要保存的已簽名請求$ response對象中的location屬性存在問題,但我無法弄清楚它是什么。 我得到兩個錯誤之一:1 .地址不被理解,firefox不知道如何打開地址,因為協議未與任何程序關聯。 當我收到該錯誤時,瀏覽器欄顯示: s:18:“ New York,New York”; 這是我要保存到變量中的location屬性的值。 第二個錯誤:在此服務器上找不到請求的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>
我建議更改此:
var location = '<?php echo $city ?>';
也許
var city = ...
您的錯誤提示這被視為等同於
window.location = ...;
由於某種原因,它是從PHP中以serialize()
字符串形式出現的。 由於來自PHP的序列化字符串不是有效的url,因此您會收到“未知”協議錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.