Advertisement
Guest User

Untitled

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