如何使用PHP讀取JSON數據響應?閱讀JSON數據帶有PHP令牌
這是代碼:
$response = Unirest\Request::get("https://montanaflynn-spellcheck.p.mashape.com/check/?text=This+sentnce+has+some+probblems.",
array(
"X-Mashape-Key" => "MY X-Mashape-Key",
"Accept" => "application/json"
)
);
,並給我這個JSON數據:
{
"original": "This sentnce has some probblems.",
"suggestion": "This sentence has some problems.",
and ...
}
我想在URL返回 「suggestion
」 與$
這是一個例子:
$user_id = '123456789'
$mytext = '?' // I WANT RETURN "suggestion" HERE !
$url = 'https://api.telegram.org/mytoken/sendMessage?chat_id='.$user_id.'&text='.$mytext
file_get_contents($url);
給我們輸入和預期輸出的一個例子。 – Dimi