Ho uno script in php che compilato con i dati per l'autenticazione stampa un array.
Ora quando eseguo lo script in un terminale questo stampa correttamente i dati mentre se lo provo su un browser no:
1-)su firefox mostra una pagina bianca anche se in fono allo script ho posizionato un echo
2-)su chrome mi da un errore 500
Ho compilato lo script e non sembra ci siano errori.
Codice PHP:
<?php
class UbuntuOneRegApp{
public $login_api_url = 'https://login.ubuntu.com/api/1.0/authentications?ws.op=authenticate&token_name=Ubuntu%20One%20@%20';
public $tell_api_url = 'https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/';
public $app_name = 'App1'; //tutto attaccato se no mostra solo la prima parola
public $user_email;
public $user_pwd;
public $conskey;
public $conssec;
public $token;
public $token_secret;
public function __construct($user_email, $user_pwd){ //variabii $user_email o $user_pwd se non danno problemi perchè uguali a sopra sono da usare
$this->user_email = $user_email;
$this->user_pwd = $user_pwd;
}
public function getTokens(){
$curl = curl_init($this->login_api_url.$this->app_name);
curl_setopt($curl, CURLOPT_USERPWD, $this->user_email.':'.$this->user_pwd);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,2);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($curl);
curl_close($curl);
$response_d = json_decode($response);
$this->conskey = $response_d->consumer_key;
$this->conssec = $response_d->consumer_secret;
$this->token = $response_d->token;
$this->token_secret = $response_d->token_secret;
$response_d->name; //nome della richiesta che farne?
return $response_d;
}
}
$u1 = new UbuntuOneRegApp("email", "pass");
$u1->getTokens();
print_r($u1->getTokens());
$oauth = new OAuth($u1->conskey,$u1->conssec,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$oauth->enableDebug();
$oauth->enableSSLChecks();
$oauth->setToken($u1->token,$u1->token_secret);
//Step 2: tell Ubuntu One about the new token (signed with the token itself)
$tell_u1_about_token_url = 'https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/' . $u1->user_email; //da fare ogni volta o solo la prima? dovrebbe essere solo la prima quasi certo
$oauth->fetch($tell_u1_about_token_url);
unset($oauth);
echo "prova prova";
?>