假設有網址印出
{"message":"123。"}
我該如何利用 php 印出這段123文字?
$request = file_get_contents('php://input');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://xxx.xxx.com/xxx/list");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$data = curl_exec($ch);
curl_close($ch);
echo $data['message'];
我這樣寫卻沒有東西?
看不太懂,现在是
https://xxx.xxx.com/xxx/list
这个网址,打开浏览器输出了{"message":"123。"}
这段内容?然后你要获取123?