arrays - PHP - run GET curl, get result -
i wanna run curl in php data php b.
this example in php (i got here http://support.qualityunit.com/061754-how-to-make-rest-calls-in-php)
//next example recieve messages specific conversation $service_url = 'http://localhost/test/getfrom.php?id=1'; $curl = curl_init($service_url); curl_setopt($curl, curlopt_returntransfer, true); $curl_response = curl_exec($curl); if ($curl_response === false) { $info = curl_getinfo($curl); curl_close($curl); die('error occured during curl exec. additioanl info: ' . var_export($info)); } curl_close($curl); $decoded = json_decode($curl_response); if (isset($decoded->response->status) && $decoded->response->status == 'error') { die('error occured: ' . $decoded->response->errormessage); } echo 'response ok!'; var_export($decoded->response); and tried example (trying use curl get, value being sent allows null)
in php b. id, run script , generate array.
i want array b a.
b run when request b.
the problem don't how array can pass b a.
please give advice thank you.
the code provided expecting json encoded array. easiest way json encode array in php b , echo page.
then curl able read contents of php b, decode , process required.
// php b <?php // check $_get params // id $id = $_get['id']; // processing, query etc .... // format , display array json echo(json_encode($result_array)); die(); ?> also note:
if (isset($decoded->response->status) && $decoded->response->status == 'error') { die('error occured: ' . $decoded->response->errormessage); } the code expecting array formatted in particular way. either match array in php b same format, or update code needs.
Comments
Post a Comment