Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. $whmcsUrl = "https://test.etravelsmart.com/etsAPI/api/getStations?";
  2. // Admin username and password
  3. $username = "888888888";
  4. $password = "**********";
  5. // Set post values
  6. $postfields = array(
  7. 'username' => $username,
  8. 'password' => md5($password),
  9. 'action' => 'GetClients',
  10. 'responsetype' => 'json',
  11. );
  12. $arrContextOptions=array(
  13. "ssl"=>array(
  14. "verify_peer"=>false,
  15. "verify_peer_name"=>false,
  16. ),
  17. );
  18.  
  19. // Call the API
  20. $ch = curl_init();
  21. curl_setopt($ch, CURLOPT_URL, $whmcsUrl);
  22. curl_setopt($ch, CURLOPT_POST, 1);
  23. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  24. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  25. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
  26. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  27. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  28. $response = curl_exec($ch);
  29. if (curl_error($ch)) {
  30. die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
  31. }
  32. curl_close($ch);
  33. // Attempt to decode response as json
  34. $jsonData = json_decode($response, true);
  35. // Dump array structure for inspection
  36. var_dump($jsonData);
  37.  
  38. {
  39. "stationList":[
  40. {"stationName":"10 dol","stationId":-1},
  41. {"stationName":"Chennai","stationId":2666}
  42. ],
  43. "apiStatus":{"success":true,"message":"SUCCESS"}
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement