Archived

This topic is now archived and is closed to further replies.

Miyanokouji

PHP API for the WebUI

Recommended Posts

I checked before I ran the script with php_info(); and I have this:

cURL Information: libcurl/7.19.4 OpenSSL/0.9.8i zlib/1.2.3 libidn/0.6.5

Does it matter that my server is running linux?

Share this post


Link to post
Share on other sites

Is this code still supposed to work? I'm getting errors all around!


$torrent = new uTorrent('localhost','9050','admin','1234');

$build = $torrent->getBuild();
echo $build;

Doesn't seem to do anything. What am I missing here?

Share this post


Link to post
Share on other sites

The latest version of the API already has rudimentary token support. There isn't anything you need to do explicitly to support it if you just use the constructor. And if you're not using the constructor... well, just look at how the constructor is setting up the token, and the rest will take care of itself.

Share this post


Link to post
Share on other sites

hey Ultima, I have a problem with your tweaked script.

I copied your script without any changes and when I try to make it login or doing any other actions

I always get this error 'could not get token'.

I made sure of course that the auth_token is enabled.

Do you have any idea why it happens?

Edit:

Oh, oops i fix that problem. But now there's a strange problem..

When the auth_token is enabled when I try to use the 'getTorrents' function i get this error:

Warning: Invalid argument supplied for foreach() in...

But when I set the webui.token_auth to FALSE, it works fine.

This is how I call to this function:

$torrents = $torrent->getTorrents();

it's not getting a thing.

Unless of course I'm using this function not the way it should be used.

After I'm doing this:

$torrents = $torrent->getTorrents();

I'm running a foreach like that:

foreach($torrents as $torrent1) {
echo $torrent1[UTORRENT_TORRENT_NAME] . "<br>";
}

Is that's how it should be?

Another Edit:

I understand that there is now a new method of verifications. Used by cookies, right?

Is there a way to implement it in this script?

Share this post


Link to post
Share on other sites

Perhaps cookies are indeed screwing things up. I'm not familiar enough with PHP/curl to be able to say how much effort it'd be, but I doubt it would be too bad, assuming curl allows you to get/set the connection's cookie details. The only thing that would need to be done is for the cookie to also be stored alongside the token when the token is being retrieved, and then have the library attach that cookie to every request it sends.

Share this post


Link to post
Share on other sites
Perhaps cookies are indeed screwing things up. I'm not familiar enough with PHP/curl to be able to say how much effort it'd be, but I doubt it would be too bad, assuming curl allows you to get/set the connection's cookie details. The only thing that would need to be done is for the cookie to also be stored alongside the token when the token is being retrieved, and then have the library attach that cookie to every request it sends.

Oh, I see.

Question is, on what base this cookie get it's value?

Need to know what value to set for this cookie for it to work.

Yeah, seems like pain in the ass ;)

Share this post


Link to post
Share on other sites

As I said, you get the cookie from the connection when you retrieve the token. µTorrent will give you a cookie; all you need to do is send that back on every request after.

Share this post


Link to post
Share on other sites
As I said, you get the cookie from the connection when you retrieve the token. µTorrent will give you a cookie; all you need to do is send that back on every request after.

Yes, but...

I checked that. When i use that PHP class for example to gain access to the webui using cURL,

and after i removed the cookie it created back then, it won't create it again when it's using cURL

(If I understood right from your message).

Share this post


Link to post
Share on other sites

Not sure if anyone still uses this or not but I figured I'd let you know I've made some improvements and added some functionality to this library.

https://github.com/tboothman/utorrent-php-api

For whatever reason a cookie is needed as well as the token when used remotely so I've added in the code to support that.

I've added in RSS filter functionality which lets you retrieve, update and add new filters.

Added composer support, because .. it's awesome.

I assume no-one else is maintaining this code? Couldn't find it elsewhere on github and this seems to be the last reference to it.

Share this post


Link to post
Share on other sites