Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add example files.

  • Loading branch information...
commit 4c84b020b461c5c13da7abc759a80014b0fdef1f 1 parent 6612e07
Ryan McCue authored
Showing with 42 additions and 0 deletions.
  1. +16 −0 examples/basic-auth.php
  2. +13 −0 examples/get.php
  3. +13 −0 examples/post.php
16 examples/basic-auth.php
View
@@ -0,0 +1,16 @@
+<?php
+
+// First, include Requests
+include('../library/Requests.php');
+
+// Next, make sure Requests can load internal classes
+Requests::register_autoloader();
+
+// Now let's make a request!
+$options = array(
+ 'auth' => array('someuser', 'password')
+);
+$request = Requests::get('http://httpbin.org/basic-auth/someuser/password', array(), $options);
+
+// Check what we received
+var_dump($request);
13 examples/get.php
View
@@ -0,0 +1,13 @@
+<?php
+
+// First, include Requests
+include('../library/Requests.php');
+
+// Next, make sure Requests can load internal classes
+Requests::register_autoloader();
+
+// Now let's make a request!
+$request = Requests::get('http://httpbin.org/get', array('Accept' => 'application/json'));
+
+// Check what we received
+var_dump($request);
13 examples/post.php
View
@@ -0,0 +1,13 @@
+<?php
+
+// First, include Requests
+include('../library/Requests.php');
+
+// Next, make sure Requests can load internal classes
+Requests::register_autoloader();
+
+// Now let's make a request!
+$request = Requests::post('http://httpbin.org/post', array(), array('mydata' => 'something'));
+
+// Check what we received
+var_dump($request);
Please sign in to comment.
Something went wrong with that request. Please try again.