Return the authorize URL.

@param array $data Query to pass to the authorization URL

@return string
182973
public function getAuthorizationURL($data = array())
    {
        if (version_compare($this->getVersion(), '1.0', '=')) {
            $response = $this->requestRequestToken();
            $data['oauth_token'] = $response->oauth_token;
        }
        
        $data = AnConfig::unbox($data);
        
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $data[ $key ] = implode(',', $value);
            }
        }
        
        $data = http_build_query($data);
        if (!empty($data)) {
            $data = '?'.$data;
        }
        
        return $this->authorize_url.$data;
    }
703606
protected function urlSafeEncode($data)
    {
        if (\is_array($data)) {
            $data = \json_encode($data, \JSON_UNESCAPED_SLASHES);
            $this->validateLastJson();
        }

        return \rtrim(\strtr(\base64_encode($data), '+/', '-_'), '=');
    }
979479
public function requestIdn($data = array())
    {
        if (count($data) == 0) {
            $this->errorMessage[] = 'IDN DATA: EMPTY';
            return $this->nameData();
        }
        $data['MERCHANT'] = $this->merchantId;
        $this->refnoext = $data['REFNOEXT'];
        unset($data['REFNOEXT']);

        foreach ($this->hashFields as $fieldKey) {
            $data2[$fieldKey] = $data[$fieldKey];
        }
        $irnHash = $this->createHashString($data2);
        $data2['ORDER_HASH'] = $irnHash;
        $this->idnRequest = $data2;
        $this->logFunc("IDN", $this->idnRequest, $this->refnoext);

        $result = $this->startRequest($this->targetUrl, $this->idnRequest, 'POST');
        $this->debugMessage[] = 'IDN RESULT: ' . $result;

        if (is_string($result)) {
            $processed = $this->processResponse($result);
            $this->logFunc("IDN", $processed, $this->refnoext);
            return     $processed;
        }
        $this->debugMessage[] = 'IDN RESULT: NOT STRING';
        return false;
    }
1023944
public static function url($path, array $data): string
    {
        $path = str_replace(' ', '%20', $path);

        return $path . '?' . http_build_query($data, '', '&', PHP_QUERY_RFC3986);
    }
559589
public static function encodeData($data)
    {
        if (\is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = \urlencode($value);
            }

            return $data;
        }

        return \urlencode($data);
    }
611569
public function getAuthorizationUrl(array $options = [])
    {
        $base   = $this->getBaseAuthorizationUrl();
        $params = $this->getAuthorizationParameters($options);
        $query  = $this->getAuthorizationQuery($params);

        return $this->appendQuery($base, $query);
    }
925906
public function requestAccessToken($data)
    {
        $secret = isset($_SESSION['oauth_token_secret']) ? $_SESSION['oauth_token_secret'] : null;

        $data = new AnConfig($data);

        $this->setToken($data->oauth_token, $secret);

        $result = $this->getRequest(array(
            'url' => $this->access_token_url,
            'data' => array('oauth_verifier' => $data->oauth_verifier),
        ))->send()->parseQUery();

        $this->setToken($result->oauth_token, $result->oauth_token_secret);

        unset($_SESSION['oauth_token_secret']);

        return $this;
    }
1318487
public function requestRequestToken($data = array())
    {
        $config = new AnConfig(array('data' => $data));
        
        $config->append(array(
            'url' => $this->request_token_url,
            'data' => array('oauth_callback' => $this->getConsumer()->callback_url),
        ));
        
        $request = $this->getRequest($config);
        $response = $request->send();

        if ($response->successful()) {
            $result = $response->parseQuery();
            $_SESSION['oauth_token_secret'] = $result->oauth_token_secret;
        } else {
            $result = '';
        }

        return $result;
    }
308166
protected function _buildAuth($data)
    {
        $out = 'OAuth ';
        $params = [];
        foreach ($data as $key => $value) {
            $params[] = $key . '="' . $this->_encode($value) . '"';
        }
        $out .= implode(',', $params);

        return $out;
    }
910517
public function generateToken(array $data = array()) {
        // http://anexsoft.com/p/125/autenticacion-usando-json-web-token
        // http://anexsoft.com/p/126/implementacion-de-json-web-token-con-php
        // https://scotch.io/tutorials/the-anatomy-of-a-json-web-token

        if (empty($this->tokenSecret)) {
            return false;
        }

        $now = time();

        // Get request object
        $req = $this->app->request;
        // Get Basic URL
        $basicUrl = $req->getUrl();
        // Get URL
        $url = $basicUrl . $req->getRootUri();

        $req->getRootUri();

        $payload = array(
            // Date on which the token is generated.
            'iat' => $now,
            // Enable token after ...
            'nbf' => $now,
            // Date until the token is valid.
            'exp' => $now + $this->tokenValidity,
            'iss' => $basicUrl,
            'typ' => $url,
            'aud' => $req->getUserAgent(),
            // Unique id of the token.
            'jti' => RandomStringGenerator::generateBasic(40)
        );

        if (!empty($data) && is_array($data)) {
            // Para guardar información del usuario.
            $payload['data'] = $data;
        }

        $token = \SlimPower\JWT\JWT::encode($payload, $this->tokenSecret);
        return $token;
    }
401055
public function send(array $data)
    {
        $url = self::SEND_URL.$this->access_token;
        $request = json_encode($data);
        $res = $this->curl->post($url, $request);

        return $res;
    }
776135
protected function curl($uri, $data)
    {
        // Force data object to array
        $data = $data ? (array) $data : $data;

        $headers = [
            'Content-Type: application/json',
            'Accept: application/json',
            'Authorization: ' . $this->apiToken
        ];

        // This is the clickatell endpoint. It doesn't really change so
        // it's safe for us to "hardcode" it here.
        $endpoint = static::API_URL . "/" . $uri;

        $curlInfo = curl_version();

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $endpoint);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_USERAGENT, static::AGENT . ' curl/' . $curlInfo['version'] . ' PHP/' . phpversion());

        // Specify the raw post data
        if ($data) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        }

        $result = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        return $this->handle($result, $httpCode);
    }
265117
protected function getId(array $data)
    {
        $result = null;

        if (isset($data['id'])) {
            $result = $data['id'];
        } elseif (isset($data['name'])) {
            $result = $data['name'];
        } else {
            #$result = sha1($data['action'] . $data['method']);
            $result = sha1(serialize($data));
        }

        return $result;
    }
647331
protected function _getCaptcha(array $data) {
		$id = !empty($data['captcha_id']) ? (int)$data['captcha_id'] : null;

		if (array_key_exists($id, $this->_captchas)) {
			return $this->_captchas[$id];
		}

		$request = Router::getRequest();
		if (!$request->getSession()->started()) {
			$request->getSession()->start();
		}
		$sessionId = $request->getSession()->id();
		if (!$sessionId && PHP_SAPI === 'cli') {
			$sessionId = 'test';
		}

		$ip = $request->clientIp();

		if (!$id) {
			$this->_captchas[$id] = null;
			return null;
		}

		$conditions = [
			'id' => $id,
			'ip' => $ip,
			'session_id' => $sessionId
		];
		$this->_captchas[$id] = $this->_captchasTable->find()->where($conditions)->first();
		return $this->_captchas[$id];
	}
433012
protected static function getUrlSafeData($data)
    {
        $remainder = strlen($data) % 4;

        if ($remainder) {
            $data .= str_repeat('=', 4 - $remainder);
        }

        return strtr($data, '-_', '+/');
    }
1108678
protected function buildUrl($url, array $data)
    {
        if (!$data) {
            return $url;
        }

        if (strpos($url, '?') === false) {
            $url .= '?';
        } elseif (substr($url, 0, -1) != '?') {
            $url .= '&';
        }

        return $url . http_build_query($data);
    }
754833
public function automaticAuthenticator($data)
	{
		$alias = $data['authenticator'];
		$alias = strip_tags($alias);
		$alias = trim($alias);
		if (strlen($alias) > 255)
		{
			$alias = substr($alias . ' ', 0, 255);
			$alias = substr($alias, 0, strrpos($alias, ' '));
		}

		return preg_replace("/[^a-zA-Z0-9]/", '', strtolower($alias));
	}