Jump to content

how to send HTTP get Request to the webservice end point?


mali

Recommended Posts

Hello,

If i am not posting this question at right location then i apologize for it.

 

My problem is: I need to send HTTP get request to the webservice end point which must include the following http headers:

 

GET / HTTP/1.1

Host: apis.live.net

Accept: application/json

Content-Type: application/json

Authorization: WRAP access_token=AuthToken (here AuthToken is the Access Token String)

 

Note: I am using OAuth for getting an access Token but for getting contents I need to send an HTTP get request.

 

Any kind of help will be appreciated.

Thanks

 

 

Link to comment
Share on other sites

Thank you for your suggestion; actually I used curl, but problem is to include the above http headers... which i did nt find through curl; however i tried this approach..

$url = "http://apis.live.net/V4.0/cid-CID/Contacts/AllContacts";

$compURL = http_build_query(array('access_token' => $accessToken));

 

$opts = array('http' => array(

        'method'  => 'GET',

        'header'  => 'Content-type: application/json',

    //'header' => 'Host: apis.live.net',

        'user_agent' => 'Authorization: WRAP',

    'content' => $compURL   

    //'content' => $postdata,

   

    )

);

 

$response = file_get_contents($url, true, $context);

but did nt recieve any response..  how can i use same stuff with curl instead of "file_get_contents()" because i also want to see which URL i am sending.

Link to comment
Share on other sites

I also tried curl as following:

$url = "http://apis.live.net/V4.0/cid-CID/Contacts/AllContacts";

 

$session=curl_init($url);

curl_setopt($session, CURLOPT_HEADER, true);

curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

 

$response = curl_exec($session);

 

if(!curl_errno($session))

{

  $info=curl_getinfo($session);

//$info = curl_getinfo($session);

 

echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];

}

 

curl_close($session);

 

But problem is how can i include following HTTP headers by only using curl:

GET / HTTP/1.1

Host: apis.live.net

Accept: application/json

Content-Type: application/json

Authorization: WRAP access_token=AuthToken

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.