Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. I've successfully finished crawling. The challenge is sending it all back home. I've tried using guzzle (which internally uses curl) and file get contents but neither can transport the data back. The data is in json encoded format like so
  2. ```
  3. {"help me":[{"href":"http:\/\/sitepoint.com","key1":"20%","key2":"20%","key3":"65%}]}
  4. ```
  5. Then I tried this
  6. ```
  7. $postClient = new GuzzleClient();
  8.  
  9.     $response = $postClient->request('POST', 'http://localhost/c.php', [
  10.         'json' => json_decode($data, true)
  11.     ]);
  12. ```
  13. and
  14. ```
  15. $postClient = new GuzzleClient();
  16.  
  17.     $response = $postClient->request('POST', 'http://localhost/c.php', [
  18.         'body' => $data,
  19.        'Content-Type' => 'application/json'
  20.     ]);
  21. ```
  22. and also
  23. ```
  24. $opts = array('http' => array('method' => 'POST', 'header'  => 'Content-Type: application/json', 'content' => json_decode($data, true)['fixtures']));
  25.  
  26.  
  27. $context = stream_context_create($opts);
  28.  
  29. $result = file_get_contents('http://localhost/c.php', false, $context);
  30. ```
  31. But when I inspect the response header using `$http_response_header`, I find it was sent using content type text/html and the c.php which contains
  32. ```
  33. var_dump($_POST);
  34. ```
  35. Says the array is empty, when there should be an array there named 'help me'. So it does get to that script but without the transport parameters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement