Advertisement
aivavic

Untitled

Dec 29th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2.  
  3. $file = 'result.json';
  4. $request = [
  5.     "EW_number" => "20450108190580",
  6.     "action" => "payments_list",
  7.     'request_uuid' => '100000069911992'
  8. ];
  9. $request_string = json_encode($request);
  10. echo 'Request : ' . $request_string . PHP_EOL;;
  11.  
  12.  
  13. $result_url = 'http://api-qa.apps.forpost.space/products/post-box';
  14. //$result_url = 'http://127.0.0.1:3000/products/post-box';
  15.  
  16. try {
  17.     $ch = curl_init($result_url);
  18.     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  19.     curl_setopt($ch, CURLOPT_POSTFIELDS, $request_string);
  20.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  21.     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  22.             'Content-Type: application/json',
  23.             'Content-Length: ' . strlen($request_string))
  24.     );
  25.     file_put_contents($file, curl_exec($ch));
  26.     curl_close($ch);
  27.  
  28.     echo 'OK';
  29. } catch (Exception $e) {
  30.     echo 'ERROR';
  31.     var_dump($e);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement