How to pull curl_exec information from a string

$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 the result:

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

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

+4
source share
2 answers

After

 $response = curl_exec($ch); 

you can try adding:

 $result = json_decode($response); echo $result->url; // or print_r($result); 
+7
source

Sounds like the answer you get:

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

JSON If you want to get the "url" response part, you first need to decode it with json_decode , and then reference the part you want: $result->url .

 $result = json_decode($response); echo $result->url; 
+3
source

All Articles