php - How to use GET on an external URL -


i using api returns json get request

eg.

https://api.domain.com/v1/account/{auth_id}/call/{call_uuid} 

returns

 {     "call_duration": 4,     "total_amount": "0.00400"   } 

how can call page within script , save call_duation , total_amount separate variables?

something following?:

$call_duration = $_get[https://api.domain.com/v1/account/{auth_id}/call/{call_uuid}, 'call_duration']; 

$_get[] contains get parameters passed code - don't generate get request.

you use curl make request:

    $ch = curl_init("https://api.domain.com/v1/account/{auth_id}/call/{call_uuid}");     curl_setopt($ch, curlopt_header, 0);     curl_setopt($ch, curlopt_returntransfer, 1);     $output = curl_exec($ch);            curl_close($ch);     $result = json_decode($output);  

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -