当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::setOption方法代码示例

本文整理汇总了PHP中Github\Client::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setOption方法的具体用法?PHP Client::setOption怎么用?PHP Client::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Github\Client的用法示例。


在下文中一共展示了Client::setOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleResponse

 public function handleResponse(UserResponseInterface $response, UserService $userService)
 {
     $fields = $response->getResponse();
     $gitHubLogin = $fields['login'];
     $accessToken = $response->getAccessToken();
     $user = $userService->findByGitHubLogin($gitHubLogin);
     if (null === $user) {
         throw new UsernameNotFoundException();
     }
     $oAuthUser = new OAuthUser($user);
     $oAuthUser->addRole('ROLE_GITHUB_USER');
     $oAuthUser->setAccessToken($accessToken);
     if (array_key_exists('name', $fields)) {
         $gitHubName = $fields['name'];
         $oAuthUser->setRealName($gitHubName);
     } else {
         $oAuthUser->setRealName($gitHubLogin);
     }
     $client = new Client();
     $client->setOption('api_version', 'v3');
     $client->authenticate($response->getAccessToken(), Client::AUTH_HTTP_TOKEN);
     /* @var \Github\Api\CurrentUser $currentUserApi */
     $currentUserApi = $client->api('current_user');
     $emails = $currentUserApi->emails();
     $allEMails = $emails->all();
     $oAuthUser->setEmail($this->getPrimaryEmailAddress($allEMails));
     return $oAuthUser;
 }
开发者ID:terretta,项目名称:gitki.php,代码行数:28,代码来源:GitHubResponseHandler.php

示例2: createWithToken

 /**
  * Create a github client wrapper with automated token-based authentication.
  *
  * @param string $token The API token to authenticate with.
  * @param string $owner The owner name of the github repository.
  * @param string $repo The name of the github repository.
  * @param string $apiUrl The base url to the github API if different from the main github site (i.e., GitHub Enterprise).
  * @return self The github client wrapper, authenticated against the API.
  */
 public static function createWithToken($token, $owner, $repo, $apiUrl = null)
 {
     $client = new Client();
     if ($apiUrl !== null) {
         $client->setOption('base_url', $apiUrl);
     }
     $client->authenticate($token, null, Client::AUTH_HTTP_TOKEN);
     return new static($client, $owner, $repo);
 }
开发者ID:ezzy1337,项目名称:release-notes,代码行数:18,代码来源:GithubClient.php

示例3: buildGitHubClient

 /**
  * @return Client
  */
 protected function buildGitHubClient()
 {
     $httpClient = new HttpClient(['base_url' => $this->config['base_url']]);
     $client = new Client($httpClient);
     if (false !== getenv('GITHUB_DEBUG')) {
         $logPlugin = LogPlugin::getDebugPlugin();
         $httpClient = $client->getHttpClient();
         $httpClient->addSubscriber($logPlugin);
     }
     $client->setOption('base_url', $this->config['base_url']);
     $this->url = rtrim($this->config['base_url'], '/');
     $this->domain = rtrim($this->config['repo_domain_url'], '/');
     return $client;
 }
开发者ID:gushphp,项目名称:gush,代码行数:17,代码来源:GitHubAdapter.php


注:本文中的Github\Client::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。