diff --git a/README.md b/README.md index 80a4b4f..f417b46 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,13 @@ $response = Unirest\Request::post("http://httpbin.org/post", $headers, $body); ### Authentication -Passing a username, password *(optional)*, defaults to Basic Authentication: +First, if you are using [Mashape][mashape-url]: +```php +// Mashape auth +Unirest\Request::setMashapeKey(''); +``` + +Otherwise, passing a username, password *(optional)*, defaults to Basic Authentication: ```php // basic auth @@ -279,7 +285,9 @@ By default is `true`. ---- -Made with ♥ from the [Mashape](https://www.mashape.com/) team +Made with ♥ from the [Mashape][mashape-url] team + +[mashape-url]: https://www.mashape.com/ [license-url]: https://github.com/Mashape/unirest-php/blob/master/LICENSE diff --git a/src/Unirest/Request.php b/src/Unirest/Request.php index dca202b..97a6630 100644 --- a/src/Unirest/Request.php +++ b/src/Unirest/Request.php @@ -87,6 +87,20 @@ class Request return self::$defaultHeaders[$name] = $value; } + /** + * Set a Mashape key to send on every request as a header + * Obtain your Mashape key by browsing one of your Mashape applications on https://www.mashape.com + * + * Note: Mashape provides 2 keys for each application: a 'Testing' and a 'Production' one. + * Be aware of which key you are using and do not share your Production key. + * + * @param string $key Mashape key + */ + public static function setMashapeKey($key) + { + return self::$defaultHeaders['X-Mashape-Key'] = $key; + } + /** * Clear all the default headers */