How can I send "x-auth-token" param to server with headers in YII.
I have this code
$data = array('customerId' => $userId);
$getdata = http_build_query(
$data
);
$options = array('http' =>
array(
'method' => 'GET',
'header' => "Content-type: application/x-www-form-urlencoded\r\n".
" Authorization: x-auth-token ".$token." \r\n",
'content' => $getdata
)
);
$context = stream_context_create($options);
$result = file_get_contents('url?'.$getdata, false, $context);
in Android we are sending data like this request.addHeader("x-auth-token", token);
I have no access to server, I am just sending requests and getting data. But after login I need to send login token to get data, but it is returns me 403.
So I think it is not sending the token. How can I do that?
$headers = array();
$headers[] = "x-auth-token: $token";
$headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=utf-8';
$state_ch = curl_init();
curl_setopt($state_ch, CURLOPT_URL,"url");
curl_setopt($state_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($state_ch, CURLOPT_HTTPHEADER, $headers);
$state_result = curl_exec ($state_ch);
$state_result = json_decode($state_result);
I have done it with CURL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With