I have used http://requests.ryanmccue.info/ and https://github.com/rmccue/Requests
I am using Request library, but any other library can also be suggested.
My code for CodeIgniter
class Home extends CI_Controller{
public function index(){
$this->load->library('PHPRequest');
$this->rest_client();
}
function rest_client(){
$user = 'myusername';
$pass = 'mypass';
$BaseApiUrl = 'myurl';
$headers = array('Accept' => 'application/json');
$options = array('auth' => new Requests_Auth_Basic(array($user, $pass)));
$request = Requests::get($BaseApiUrl, $headers, $options);
var_dump($request->status_code);
var_dump($request->body);
}
}
But I am getting the following error:
int(401) string(28) "HTTP Digest: Access denied. "