session.php 549 B

123456789101112131415161718192021222324
  1. <?php
  2. // First, include Requests
  3. include('../library/Requests.php');
  4. // Next, make sure Requests can load internal classes
  5. Requests::register_autoloader();
  6. // Set up our session
  7. $session = new Requests_Session('http://httpbin.org/');
  8. $session->headers['Accept'] = 'application/json';
  9. $session->useragent = 'Awesomesauce';
  10. // Now let's make a request!
  11. $request = $session->get('/get');
  12. // Check what we received
  13. var_dump($request);
  14. // Let's check our user agent!
  15. $request = $session->get('/user-agent');
  16. // And check again
  17. var_dump($request);