Rourke Posted January 22, 2012 Report Share Posted January 22, 2012 I love the fact uTorrent has an API for programmers, except I have no clue how to start this with PHP. I simply want to load a torrent file (URL) in my utorrent client.The way the token system works and how everything is explained in the documentation is very vague to say the least. You need the token to see the token?Normal authentication methods through HTTP headers don't seem to work. A simple and solid method to get the JSON/HTML that proved itself over and over would be this way:<?php$username = 'username';$password = 'password';$url = 'http://[my-external-ip]:4321/gui/token.html';$context = stream_context_create(array( 'http' => array( 'header' => "Authorization: Basic " . base64_encode("$username:$password") )));$data = file_get_contents($url, false, $context);print_r($data);?>Yet I get a timeout. I've also tried cURL without any luck. Am I missing something here?I have to add it's not a problem for me to reach the token.html when I type in the address in the browser. Link to comment Share on other sites More sharing options...
Ultima Posted January 23, 2012 Report Share Posted January 23, 2012 http://forum.utorrent.com/viewtopic.php?id=58111HTTP cookies. Link to comment Share on other sites More sharing options...
Rourke Posted January 23, 2012 Author Report Share Posted January 23, 2012 I've read that and it's still not clear to me how I should request such HTTP cookies with PHP. I googled, searched and tried for over 12 hours now. Some actual code examples (not what I'm supposed to send and receive) would be very helpfull. Or any hint in the right direction Link to comment Share on other sites More sharing options...
Sanity Posted January 30, 2012 Report Share Posted January 30, 2012 Rourke I don't use PHP but I can explain a few things to you. When you send a request to obtain a token from uTorrent you will also receive the cookie in the same return. So you won't need to request the cookie. here is an example return I get from a token request:HTTP/1.1 200 OKConnection: keep-aliveContent-Length: 121Content-Type: text/htmlSet-Cookie: GUID=b8nUSjNaRmMu7OUPIyQj; path=/Cache-Control: no-cache<html><div id='token' style='display:none;'>5RsdSpL0je-SGs95zOZ2MW6kinLDLPa74LgQ9HnXfjWb3BvOXEuVZrlaJU8AAAAA</div></html>As you can see the cookie which is "b8nUSjNaRmMu7OUPIyQj" is also returned as well when the token request is returned. I would submit a PHP question to a PHP forum on the internet somewhere. You probably would get a quicker response. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.