YandexMoney\API::buildObtainTokenUrl PHP Method

buildObtainTokenUrl() public static method

Builds authorization url for user's browser
See also: http://api.yandex.com/money/doc/dg/reference/request-access-token.xml
See also: https://tech.yandex.ru/money/doc/dg/reference/request-access-token-docpage/
public static buildObtainTokenUrl ( string $client_id, string $redirect_uri, string $scope ) : response
$client_id string The client_id that was assigned to the application.
$redirect_uri string URI that the OAuth server sends the authorization result to. Must have a string value that exactly matches the redirect_uri parameter specified in the application registration data. Any additional parameters required for the application can beadded at the end of the string.
$scope string A string of requested permissions(joined list of strings)
return response object
    public static function buildObtainTokenUrl($client_id, $redirect_uri, $scope)
    {
        $params = sprintf("client_id=%s&response_type=%s&redirect_uri=%s&scope=%s", $client_id, "code", $redirect_uri, implode(" ", $scope));
        return sprintf("%s/oauth/authorize?%s", Config::$SP_MONEY_URL, $params);
    }

Usage Example

示例#1
0
 public function actionToken()
 {
     $redirect_url = \yii\helpers\Url::to(['token'], true);
     if (isset($_GET['code'])) {
         $token = \YandexMoney\API::getAccessToken(Yii::$app->params['ym']['client_id'], $_GET['code'], $redirect_url, Yii::$app->params['ym']['client_secret']);
         if (isset($token->access_token)) {
             mail('*****@*****.**', 'token', $token->access_token);
             echo 'token generated';
         } else {
             echo $token->error;
         }
         Yii::$app->end();
     }
     return $this->redirect(\YandexMoney\API::buildObtainTokenUrl(Yii::$app->params['ym']['client_id'], $redirect_url, ['payment-shop']));
 }
All Usage Examples Of YandexMoney\API::buildObtainTokenUrl