PHP Classes

File: includes/src/vendor/rmccue/requests/docs/authentication.md

Recommend this page to a friend!
  Classes of Subin Siby   Lobby   includes/src/vendor/rmccue/requests/docs/authentication.md   Download  
File: includes/src/vendor/rmccue/requests/docs/authentication.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Lobby
Web OS to install and run Web applications
Author: By
Last change: Lobby 1.0 Cobra
Date: 7 years ago
Size: 925 bytes
 

Contents

Class file image Download

Authentication

Many requests that you make will require authentication of some type. Requests includes support out of the box for HTTP Basic authentication, with more built-ins coming soon.

Making a Basic authenticated call is ridiculously easy:

$options = array(
	'auth' => new Requests_Auth_Basic(array('user', 'password'))
);
Requests::get('http://httpbin.org/basic-auth/user/password', array(), $options);

As Basic authentication is usually what you want when you specify a username and password, you can also just pass in an array as a shorthand:

$options = array(
	'auth' => array('user', 'password')
);
Requests::get('http://httpbin.org/basic-auth/user/password', array(), $options);

Note that POST/PUT can also take a data parameter, so you also need that before $options:

Requests::post('http://httpbin.org/basic-auth/user/password', array(), null, $options);