下面是我的代码,我试图在 php 字符串中获取特定的 mashape api 响应(运算符)。
require_once 'vendor/autoload.php';
$response = Unirest\Request::get("https://sphirelabs-mobile-number-portability-india-operator-v1.p.mashape.com/index.php?number=8055144322",
array(
"X-Mashape-Key" => "XXXXXXXXX",
"Accept" => "application/json"
)
);
json_decode($response, true);
echo $response['operator'];
回复:
Unirest\Response Object (
[code] => 200
[raw_body] => {"Telecom circle":"Maharashtra","Operator":"Reliance GSM","Is MNP":"False"}
[body] => stdClass Object (
[Telecom circle] => Maharashtra
[Operator] => Reliance GSM
[Is MNP] => False
)
[headers] => Array ( [0] => HTTP/1.1 200 OK [Accept-Ranges] => none [Content-Encoding] => gzip [Content-Type] => application/json [Date] => Thu, 19 Feb 2015 14:04:39 GMT [Server] => Mashape/5.0.6 [Vary] => Accept-Encoding [Content-Length] => 91 [Connection] => keep-alive ) )