Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // echo api_call($input,"city_search","master"); exit;
- $url = ''; # API Link
- $post = array('input' => $city);
- // $headers = array('content-type:application/json');
- $ch = curl_init(); # initialize curl object
- curl_setopt($ch, CURLOPT_URL, $url); # set url
- curl_setopt($ch, CURLOPT_POST, 1); #post data
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post); #post data field
- // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); # receive server response
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); # do not verify SSL
- $data = curl_exec($ch); # execute curl
- $res = json_decode($data);
- $city_array = array('cities' => $res->data);
- header("Content-type: application/json; charset=utf-8");
- echo json_encode($city_array, JSON_PRETTY_PRINT);
- // return $data;
- // $httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); # http response status code
- // curl_close($ch); # close curl
- ?>
Add Comment
Please, Sign In to add comment