i know question not going clear similar questions on here talking sending headers, theres alot of questions similar not answering specifically, sorry if answer extremely obvious,
so ive got apk sends x-api-key
in header php conversion of code is..
$url = 'example.something.org/test.php'; $data = "$some_data"; $curl = curl_init(); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_post, true); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_postfields, $data); curl_setopt($curl, curlopt_header, true); curl_setopt($curl, curlopt_httpheader, array("x-api-key"=>"find_meeeeeeee"));
what want collect x-api-key
, store variable can send request test.php similar 1 shown, not option run request directly apk dont want data stored client side, need x-api-key
request being sent server, technically apk->my_server->external_server
i have tried using print_r
$_post
, $_server
echoed keys in header()
multiple other things cant think of right ive tried , searched google as possible
please link answer if has been answered in advance,
**edit: ** ive tried using js code gives me exact same headers
var req = new xmlhttprequest(); req.open('get', document.location, false); req.send(null); var headers = req.getallresponseheaders().tolowercase(); alert(headers);
set header as:-
$headers = array( 'content-type: application/json', "x-api-key"=>"find_meeeeeeee" ); curl_setopt($curl, curlinfo_header_out, true); curl_setopt($curl, curlopt_httpheader, $headers);
in test.php
file write lines:-
foreach (getallheaders() $name => $value) { echo "$name: $value\n"; }
hope :)
Comments
Post a Comment