Monday, 25 May 2015

How to send Auth key in header in php..

Simple use this code to send key and extra header to server in php.

$url = 'localhost/newapi/client/';
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => "Content-Type: application/json\r\n"."Authorization: ".<authkey>."\r\n",
            'content' => $data,
            'timeout' => 60
            )
        );

    $context  = stream_context_create($opts);
    $result = file_get_contents($url, false, $context, -1, 40000);

    return $result;

No comments:

Post a Comment