【问题标题】:Can't figure out why I'm getting Server errors from my PHP code无法弄清楚为什么我的 PHP 代码会出现服务器错误
【发布时间】:2013-04-08 01:47:45
【问题描述】:

在这个 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>

【问题讨论】:

    标签: php facebook plugins registration


    【解决方案1】:

    我建议改变这个:

    var location = '<?php echo $city ?>';
    

    也许

    var city = ...
    

    您的错误表明这被视为等同于

    window.location = ...;
    

    由于某种原因,它作为 serialize()' 字符串从 PHP 中出来。由于来自 PHP 的序列化字符串不是有效的 url,因此您会收到“未知”协议错误。

    【讨论】:

    • 天哪。有效。非常感谢。我不知道问题是什么。你帮了大忙。
    猜你喜欢
    • 2023-02-11
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 2017-06-15
    • 1970-01-01
    • 2021-11-03
    • 2013-11-21
    相关资源
    最近更新 更多