繁体   English   中英

无法弄清楚为什么我的PHP代码出现服务器错误

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM