Mashape API PHP-没有显示数据?
我很难从mashape API中获取任何数据,我已经发布了UNIREST帖子,但是我无法将数据回显给自己,这是调用应该返回的内容Mashape API PHP-没有显示数据?,php,api,unirest,mashape,Php,Api,Unirest,Mashape,我很难从mashape API中获取任何数据,我已经发布了UNIREST帖子,但是我无法将数据回显给自己,这是调用应该返回的内容 { "result": { "name": "The Elder Scrolls V: Skyrim", "score": "92", "rlsdate": "2011-11-11", "genre": "Role-Playing", "rating": "M", "platform": "PlayStation 3", "publisher": "Bethesda
{
"result": {
"name": "The Elder Scrolls V: Skyrim",
"score": "92",
"rlsdate": "2011-11-11",
"genre": "Role-Playing",
"rating": "M",
"platform": "PlayStation 3",
"publisher": "Bethesda Softworks",
"developer": "Bethesda Game Studios",
"url": "http://www.metacritic.com/game/playstation-3/the-elder-scrolls-v-skyrim"
}
}
我的代码
require_once 'MYDIR/mashape/unirest-php/lib/Unirest.php';
$response = Unirest::post(
"https://byroredux-metacritic.p.mashape.com/find/game",
array(
"X-Mashape-Authorization" => "MY API AUTH CODE"
),
array(
"title" => "The Elder Scrolls V: Skyrim",
"platform" => undefined
)
);
echo "$response->body->name";
?>
有谁能建议我如何让它呼应“名字”吗
任何帮助都将不胜感激:)您试图显示正文的方式似乎阻止您看到响应中的错误,该错误告诉您属性
平台
必须是编号
尝试使用json\u encode($response->body)
查看完整响应:
<?php
require_once 'lib/Unirest.php';
$response = Unirest::post(
"https://byroredux-metacritic.p.mashape.com/find/game",
array(
"X-Mashape-Authorization" => "-- your authorization key goes here --"
),
array(
"title" => "The Elder Scrolls V: Skyrim",
"platform" => 1 # try placing undefined here.
)
);
echo json_encode($response->body);
?>
$result = $response->body->result;
echo "{$result->name} has a score of [{$result->score}]";