如何从字符串中提取curl_exec信息

Gre*_*reg 4 php curl

$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); 
Run Code Online (Sandbox Code Playgroud)

之后curl_exec(),我得到的结果:

{"name":"xxxxxxxxxxxxxxxxxxxxxx","url":"http://xxxxxxxx.com"}

如何info(http://xxxxxxxx.com)从字符串中提取网址?

Jos*_*ano 8

$response = curl_exec($ch); 
Run Code Online (Sandbox Code Playgroud)

你可以尝试添加:

$result = json_decode($response);
echo $result->url; // or print_r($result);
Run Code Online (Sandbox Code Playgroud)

  • @Greg此代码完全适合您在原始问题中所说的内容.请修改您的代码更新此帖子及相关信息. (2认同)