PHP 注意:试图获取 属性 的非对象错误

PHP Notice: Trying to get property of non-object error

我在 AngularJS 中使用 Factory,脚本是

app.factory('GetCountryService', function ($http, $q) {
        return {
            getCountry: function(str) {
                // the $http API is based on the deferred/promise APIs exposed by the $q service
                // so it returns a promise for us by default
                var url = "https://www.bbminfo.com/sample.php?token="+str;
                return $http.get(url)
                    .then(function(response) {
                        if (typeof response.data.records === 'object') {
                            return response.data.records;
                        } else {
                            // invalid response
                            return $q.reject(response.data.records);
                        }

                    }, function(response) {
                        // something went wrong
                        return $q.reject(response.data.records);
                    });
            }
        };

    });

我的输出响应屏幕截图:

我的PHP脚本:

<?php



header("Access-Control-Allow-Origin: *");

header("Content-Type: application/json; charset=UTF-8");



session_start();


$ip = $_SERVER['REMOTE_ADDR'];

$dbname = "xyzData";
$link = mysql_connect("localhost", "Super", "Super") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");

$uid = "";
$txt = 0;
$outp = "";

$data    = file_get_contents("php://input");
$objData = json_decode($data);

if (isset($objData->token))
    $uid = mysql_real_escape_string($objData[0]->token, $link);
else if(isset($_GET['uid']))
    $uid = mysql_real_escape_string($_GET['uid']);
else
    $txt += 1;

$outp ='{"records":[{"ID":"' . $objData->token . '"}]}';
echo($outp);

?>

我收到 error_log 消息是

[18-Mar-2016 21:40:40 America/Denver] PHP Notice: Trying to get property of non-object in /home/sample.php

$objData->token$objData->token[0] 我都试过了。但我收到了同样的错误通知。请帮助我...

我尝试了 Post Notice: Trying to get property of non-object error, But it fails so, I raised 50 Bounty Points for this post. I tried to update my requirement in that post Question https://whosebug.com/review/suggested-edits/11690848 中提供的解决方案,但编辑被拒绝,所以我将我的要求作为一个新问题发布。请帮助我...

$objData 似乎不是对象。

试试 $objData['token'].

或者回显对象 $objData 并尝试找出它的结构。

AngularJS 没有发送任何对象,而是传递了 GET 元素。

只需使用 $_GET['uid']

即可访问值