laravel - php how to pass authorization bearer in unirest -


i have unirest code running in laravel 4.2: (doesn't work)

<?php     $headers = array('authorization', 'bearer tokenasdkaskdn231das2');     $body    = array();     $respons = unirest\request::get("https://api.request", $headers, $body); ?> // , <?php   unirest\request::auth('tokenasdkaskdn231das2', '');   $header  = array();   $body    = array();   $respons = unirest\request::get("https://api.request", $headers, $body); ?> 

i tried running in getpostman

url: - https://api.request

header: authorization : bearer tokenasdkaskdn231das2

it works. don't why not in unirest.


i have working code using auth basic:

authorization: basic c2tfdgvzdf9unta0owfhnja1m2m5ytaymtdizwe3oda3mgzizjuwmto=

in php:

unirest\request::auth('c2tfdgvzdf9unta0owfhnja1m2m5ytaymtdizwe3oda3mgzizjuwmto=', '');

this 1 simple.

this correct, said: unirest\request::auth('token here', '');

this not $headers = array('authorization', 'bearer tokenasdkaskdn231das2');

because $headers getting array,

it should array('authorization' => 'bearer tokenhere');

do not compare header , auth


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -