nicoSWD / put.io-api-v2

PHP OAuth API wrapper for put.io (putio)
MIT License
15 stars 5 forks source link

Can't upload files #4

Closed dprevite closed 9 years ago

dprevite commented 9 years ago

When I try this, tweaked from the docs:

// Upload a file.
$file = '/path/to/file.torrent';
$putio->files->upload($file);

I'm getting the following response from the API even though other API calls (getting files) work just fine.

{
  "error_message": "The server could not verify that you are authorized to access the URL requested.  You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.", 
  "error_type": "Unauthorized", 
  "error_uri": "http://api.put.io/v2/docs", 
  "status": "ERROR", 
  "status_code": 401
}
nicoSWD commented 9 years ago

Thanks!

I just took a quick look at it, and I can confirm the issue. Not sure yet why this is happening, but a quick workaround until a proper fix is pushed would be this:

In Helpers/PutIO/PutIOHelper.php, change uploadFile() to

protected function uploadFile($path, array $params = array())
{
    $path .= '?oauth_token=XXXXXXX';
    return $this->request('POST', $path, $params);
}

And after creating the instance, set the HTTP engine to "Native" (cURL causes issues regardless)

$putio->setHTTPEngine('Native');

Will push a proper fix as soon as I know what's happening.

Thank you!

nicoSWD commented 9 years ago

The issue has been addressed.

Thanks again!