Jump to content

file_get_contents, then how to use the contents?


oskare100

Recommended Posts

Hello,

I've a request that looks about like this:

 

        $request_url1 = "http://api.ddddddd.com/http/auth?api_id=$ddd_appid&user=$ddd_user&password=$ddd_passw";
        $request_sessionid = file_get_contents($request_url1);

 

Back from that I should get an ID I need to include in another request, if I write the address in a normal browser the response looks like this:

 

OK: 464fhjolilw8ad6awde8844

 

So when I make the request to http://api.ddddddd.com/http/auth?api_id=$ddd_appid&user=$ddd_user&password=$ddd_passw I need to assign the ID I get back (464fhjolilw8ad6awde8844 in this case) to a variable so I can use it in another request, but I can't figure out how to do that so I need help...

 

/Oskar

 

Link to comment
Share on other sites

Are you getting back the string?

 

If so, you can do

<?php
        $request_url1 = "http://api.ddddddd.com/http/auth?api_id=$ddd_appid&user=$ddd_user&password=$ddd_passw";
        list($ok,$request_sessionid) = array_map('trim',explode(':',file_get_contents($request_url1)));
        $echo $request_sessionid;  // just to check;
?>

 

Ken

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.