Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $whmcsUrl = "https://test.etravelsmart.com/etsAPI/api/getStations?";
- // Admin username and password
- $username = "888888888";
- $password = "**********";
- // Set post values
- $postfields = array(
- 'username' => $username,
- 'password' => md5($password),
- 'action' => 'GetClients',
- 'responsetype' => 'json',
- );
- $arrContextOptions=array(
- "ssl"=>array(
- "verify_peer"=>false,
- "verify_peer_name"=>false,
- ),
- );
- // Call the API
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $whmcsUrl);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- $response = curl_exec($ch);
- if (curl_error($ch)) {
- die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
- }
- curl_close($ch);
- // Attempt to decode response as json
- $jsonData = json_decode($response, true);
- // Dump array structure for inspection
- var_dump($jsonData);
- {
- "stationList":[
- {"stationName":"10 dol","stationId":-1},
- {"stationName":"Chennai","stationId":2666}
- ],
- "apiStatus":{"success":true,"message":"SUCCESS"}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement