dtdfj08626 2017-08-08 12:48 采纳率: 0%
浏览 51


I'am sending JSON data to an URL and then I also recieve JSON.
I'm using PHP CURL to recieve the data and show it on my page.
My Problem is that I can only get the json completely and I can't show only a selected value from that JSON data.
I got this already:

//API Url
$url = "https://auth.unilinxx.com/test";

//Initiate cURL.
$ch = curl_init($url);

//The JSON data.
$jsonData = array("value" => "Gideon lol");

//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);

//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);

//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); 

//Execute the request
$result = curl_exec($ch);

$values = json_decode($result, true);

echo $values["value"];

My result is: {"value":"U heeft Gideon lol gestuurd."}

I like to have only this: U heeft Gideon lol gestuurd.

How can I do that?

  • 写回答



      相关推荐 更多相似问题


      • ¥30 关于#网络安全#的问题:非对称加密验证
      • ¥20 关于线性代数里施密特正交化和QR分解的疑问
      • ¥15 matlab超类包含解析错误
      • ¥15 python拖拽文件问题
      • ¥15 执行import paddle代码出现错误如何解决?
      • ¥15 hisat2align exited with value 137
      • ¥15 寻找大学生合作开发软件(Delphi)
      • ¥30 AndroidBench&eMMC内存测试速度&Android
      • ¥15 W10 文件共享失败 怎么解决
      • ¥20 b站私信完整导出的方法