Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pull curl_exec info from string

Tags:

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); 

After curl_exec() I get a result of:

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

How can I pull the url info(http://xxxxxxxx.com) from the string?

like image 437
Greg Avatar asked Feb 09 '23 08:02

Greg


1 Answers

After

$response = curl_exec($ch); 

you can try to add:

$result = json_decode($response);
echo $result->url; // or print_r($result);
like image 72
Josua Marcel C Avatar answered Feb 11 '23 23:02

Josua Marcel C