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;
}
/** * 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)); }