proxy.php 552 B

123456789101112131415161718
  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. // Now let's make a request via a proxy.
  7. $options = array(
  8. 'proxy' => '127.0.0.1:8080', // syntax: host:port, eg 12.13.14.14:8080 or someproxy.com:3128
  9. // If you need to authenticate, use the following syntax:
  10. // 'proxy' => array( '127.0.0.1:8080', 'username', 'password' ),
  11. );
  12. $request = Requests::get('http://httpbin.org/ip', array(), $options );
  13. // See result
  14. var_dump($request->body);