Zendesk\API\Utilities\OAuth::getAuthUrl PHP Méthode

getAuthUrl() public static méthode

Generates an oAuth URL.
public static getAuthUrl ( string $subdomain, array $options, string $domain = 'zendesk.com' ) : string
$subdomain string
$options array
$domain string
Résultat string
    public static function getAuthUrl($subdomain, array $options, $domain = 'zendesk.com')
    {
        $queryParams = ['response_type' => 'code', 'client_id' => null, 'state' => null, 'redirect_uri' => null, 'scope' => 'read write'];
        $options = array_merge($queryParams, $options);
        $oAuthUrl = "https://{$subdomain}.{$domain}/oauth/authorizations/new?";
        // Build query and remove empty values
        $oAuthUrl .= http_build_query(array_filter($options));
        return $oAuthUrl;
    }

Usage Example

 /**
  * Tests if the OAuth::getAuthUrl function returns a correct URL.
  */
 public function testAuthUrl()
 {
     $params = ['client_id' => 'test_client', 'state' => 'St8fulbar'];
     $expected = 'https://z3ntestsub.zendesk.com/oauth/authorizations/new?response_type=code&client_id=test_client&state=St8fulbar&scope=read+write';
     $this->assertEquals($expected, OAuth::getAuthUrl('z3ntestsub', $params));
 }
All Usage Examples Of Zendesk\API\Utilities\OAuth::getAuthUrl