I have searched the whole internet trying to find a simple example that could point me in the right direction, but no luck, so here comes my questions:
I want to log into Ubuntu One and sync (or almost read) files from my web page, all done with PHP. The needs to reach files are all described in that page: https://one.ubuntu.com/developer/account_admin/issue_tokens/cloud/
I am able to complete the first request with:
$url = 'https://login.ubuntu.com/api/1.0/authentications?ws.op=authenticate&token_name=Ubuntu%20One%20@%20try1';
$data = curlPetition(array('URL'=>$url,'USERPWD'=>'user:pass'));
$ar = fopen('uOne','w');fwrite($ar,$data['responseBody']);fclose($ar);
$tokenA = json_decode($data['responseBody'],1);
Ok, curlPetition only makes basic curl petitions. Note that you need a valid user:pass ubuntu one account. I get the response correctly in json with "consumer_secret" , "token" , "consumer_key" , "name" , "token_secret". Even the entry appear listed in the ubuntu one's granted apps.
I hace installed the most new OAuth PCL php extensión and its working good. but when I try to:
$api_url = 'https://one.ubuntu.com/api/file_storage/v1/';
$conskey = $tokenA['consumer_key'];
$conssec = $tokenA['consumer_secret'];
$token = $tokenA['token'];
$secret = $tokenA['token_secret'];
$oauth = new OAuth($conskey,$conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($token,$secret);
$oauth->fetch($api_url.'~/Ubuntu%20One/');
print_r($oauth->getLastResponse());
I get moved to the "OpenID transaction in progress" page where you pass when doing a manual web login. Im definitely doing something wrong. I tried to get the second step from https://one.ubuntu.com/developer/account_admin/issue_tokens/cloud/ with $oauth->fetch, $oauth->getAccessToken and $oauth->getRequestToken, same response on all with 403 error :S
I was trying to figure how the payload works but the main examples are writed with python, using "import ubuntuone.couch.auth as auth" that makes the token stuff almost automatic.
I'll love to get some hints. Thanks