"request": [
{
"title": "Google Custom Search - flowers",
"totalResults": 10300000,
"searchTerms": "flowers",
}
]
},
我试过这个:
$response = file_get_contents('https://www.googleapis.com/customsearch/v1?key=INSERT-YOUR-KEY&cx=013036536707430787589:_pqjad5hr1a&q=flowers&alt=json
');
$json = json_decode($response);
echo "Total Result:".$json->request->totalResults;
但我一无所获。 需要帮助请。感谢。
答案 0 :(得分:1)
在你的帖子里,所有的json都看不见了。在我的测试中它适用于此:
$ json->查询 - >请求[0] - >使用totalResults;
答案 1 :(得分:0)
也许尝试if(!is_null($ json-> request-> totalResults))条件,看看你是否得到了回复。