$appID='xxxxx';
$restID='xxxx';
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data2);
$headers = array(
'X-Parse-Application-Id: ' .$appID.'',
'X-Parse-REST-API-Key: ' .$restID.'',
'Content-Type: image/jpeg'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, xxxxx);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
在curl_exec()
之后我得到了结果:
{"name":"xxxxxxxxxxxxxxxxxxxxxx","url":"http://xxxxxxxx.com"}
如何从字符串中提取网址info(http://xxxxxxxx.com)
?
答案 0 :(得分:8)
之后
$response = curl_exec($ch);
您可以尝试添加:
$result = json_decode($response);
echo $result->url; // or print_r($result);
答案 1 :(得分:3)
看起来你得到的回应是:
{"name":"xxxxxxxxxxxxxxxxxxxxxx","url":"http://xxxxxxxx.com"}
是JSON。如果您想要获得响应的“网址”部分,首先需要使用json_decode
对其进行解码,然后引用您想要的部分:$result->url
。
$result = json_decode($response);
echo $result->url;