$urlToken = "http://qiwi.com/oauth/authorize";
$header = array();
$header[] = "Content-Type: application/x-www-form-urlencoded";
$header[] = "Accept: application/json";
if ($curl = curl_init()) {
curl_setopt($curl, CURLOPT_URL, $urlToken);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_POSTFIELDS, "response_type=code&client_id=api_wallet_private&client_software=api&token=ваш_активный_токен");
$newToken = curl_exec($curl);
curl_close($curl);
$newToken = json_decode($newToken);
}
$urlToken = "http://qiwi.com/oauth/token";
$header = array();
$header[] = "Content-Type: application/x-www-form-urlencoded";
$header[] = "Accept: application/json";
if ($curl = curl_init()) {
curl_setopt($curl, CURLOPT_URL, $urlToken);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_POSTFIELDS, "grant_type=authorization_code&client_id=api_wallet_private&client_secret=hTFPyt&code={$newToken->code}");
$tokenType = curl_exec($curl);
curl_close($curl);
$tokenType = json_decode($tokenType);
}
echo $tokenType->access_token;
//выведет на экран 10-летний токен, который можно использовать вместо 6-месячного как раньше.