fork download
  1. <?php
  2.  
  3. function isValidApiResponse()
  4. {
  5. $url = "https://p...content-available-to-author-only...r.com/api/v1/affiliate/getBasicDetails";
  6.  
  7. $data = [
  8. "MobileNo" => "nGyulSschikrQE6kR+uVkg=="
  9. ];
  10.  
  11. $headers = [
  12. "Content-Type: application/json",
  13. "Cookie: _abck=E24418EF155538F18D3DA91536273672~-1~YAAQ7AVaaKb8E/6RAQAAZQ0xBAzqAdu763o4eslwcV+vvNLwg4URhKTyMMNvpHwB2TL5mMTszCS2gAKofhgygfDS12eWVpZvU+ROaB9QjYNgEstkaSX6YQcpvcdSfm8vzEIzwGdsTFx1cSr6oMj4BkCD9S0aZVfPeqqJTWeDnnEJ2szsr+Qtw9+fEl0q9/AnoqB3QqUUeriDB6e6bfPUG/qY1Dux7S1XZtpT4zIvcgTpgpg9NG6L9WgQzZEWZ3pzb35g1MdbCLQtiXAAT30mEO2g7aSTQcbJRMS2qthsfbg3XTlp0ZL+pjc9BFREcBG3s1xgGYtGdO1tm3pP5IKTcSon3iaeQFlxnqd539ykt3MHWjpdOYa4FZyscHEG7a7dRYW8/h8dis4Mit/U3pNJZVD6~-1~-1~-1"
  14. ];
  15.  
  16. // Initialize cURL session
  17. $ch = curl_init($url);
  18.  
  19. // Set cURL options
  20. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  21. curl_setopt($ch, CURLOPT_POST, true);
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  23. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  24.  
  25. // Execute the request and capture the response
  26. $response = curl_exec($ch);
  27.  
  28. // Check for cURL errors
  29. if ($response === false) {
  30. curl_close($ch);
  31. return false;
  32. }
  33.  
  34. // Close cURL session
  35. curl_close($ch);
  36.  
  37. // Decode the JSON response
  38. $responseData = json_decode($response, true);
  39.  
  40. print_r($responseData);
  41.  
  42. // Validate response data
  43. if (
  44. isset($responseData['error'], $responseData['data']) &&
  45. $responseData['error'] === false &&
  46. is_array($responseData['data']) &&
  47. count($responseData['data']) > 0
  48. ) {
  49. return true;
  50. } else {
  51. return false;
  52. }
  53. }
  54.  
  55. // Call the function and display the result
  56. $result = isValidApiResponse();
  57. echo $result ? 'true' : 'false';
  58.  
Success #stdin #stdout 0.03s 26628KB
stdin
Standard input is empty
stdout
false