From 14a784e41629c7785072b3654aa1b0459eebdb19 Mon Sep 17 00:00:00 2001 From: Montana Flynn Date: Tue, 16 Apr 2013 14:43:34 -0700 Subject: [PATCH] Added syntax highlighting --- README.md | 57 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ef0d618..3ecbb62 100644 --- a/README.md +++ b/README.md @@ -14,40 +14,47 @@ Download the PHP library from Github, and require in your script like so: ### Creating Request So you're probably wondering how using Unicorn makes creating requests in PHP easier, let's look at a working example: - $response = Unicorn::post("http://httpbin.org/post", array( "Accept" => "application/json" ), - array( - "parameter" => 23, - "foo" => "bar" - ) - ); +```php +$response = Unicorn::post("http://httpbin.org/post", array( "Accept" => "application/json" ), + array( + "parameter" => 23, + "foo" => "bar" + ) +); +``` ### File Uploads To upload files in a multipart form representation simply place an @ symbol before the path: - $response = Unicorn::post("http://httpbin.org/post", array( "Accept" => "application/json" ), - array( - "file" => "@/tmp/file.txt" - ) - ); +```php +$response = Unicorn::post("http://httpbin.org/post", array( "Accept" => "application/json" ), + array( + "file" => "@/tmp/file.txt" + ) +); + ``` ### Custom Entity Body Sending a custom body such as a JSON Object rather than a string or form style parameters we utilize json_encode for the body: - - $response = Unicorn::post("http://httpbin.org/post", array( "Accept" => "application/json" ), - json_encode( - array( - "parameter" => "value", - "foo" => "bar" - ) - ) - ); +```php +$response = Unicorn::post("http://httpbin.org/post", array( "Accept" => "application/json" ), + json_encode( + array( + "parameter" => "value", + "foo" => "bar" + ) + ) +); +``` ### Request Reference - Unicorn::get($url, $headers = array()); - Unicorn::post($url, $headers = array(), $body = NULL); - Unicorn::put($url, $headers = array(), $body = NULL); - Unicorn::patch($url, $headers = array(), $body = NULL); - Unicorn::delete($url, $headers = array()); +```php +Unicorn::get($url, $headers = array()); +Unicorn::post($url, $headers = array(), $body = NULL); +Unicorn::put($url, $headers = array(), $body = NULL); +Unicorn::patch($url, $headers = array(), $body = NULL); +Unicorn::delete($url, $headers = array()); +``` `url` Endpoint, address, or uri to be acted upon and requested information from.