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


PHP User::getProviderAccessToken方法代码示例

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


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

示例1: discover

 /**
  * {@inheritDoc}
  */
 public function discover(User $user)
 {
     $client = clone $this->client;
     $client->setDefaultOption('headers/Authorization', 'token ' . $user->getProviderAccessToken('github'));
     $request = $client->get('/user/orgs');
     $response = $request->send();
     $data = $response->json();
     $orgRequests = [$client->get('/user/repos')];
     foreach ($data as $org) {
         $this->logger->debug(sprintf('adding "' . $org['repos_url'] . '" for crawl'));
         $orgRequests[] = $client->get($org['repos_url']);
     }
     $orgResponses = $client->send($orgRequests);
     $composerRequests = [];
     foreach ($orgResponses as $orgResponse) {
         $this->fetchRepos($orgResponse);
         if ($orgResponse->hasHeader('link')) {
             $link = $orgResponse->getHeader('link');
             if (preg_match('/.* <(.+?)\\?page=(\\d+)>; rel="last"$/', $link, $matches)) {
                 $pagesRequests = [];
                 for ($i = 2; $i <= $matches[2]; $i++) {
                     $this->logger->debug(sprintf('adding "' . ($matches[1] . '?page=' . $i) . '" for crawl'));
                     $pagesRequests[] = $client->get($matches[1] . '?page=' . $i);
                 }
                 $pagesResponses = $client->send($pagesRequests);
                 foreach ($pagesResponses as $pagesResponse) {
                     $this->fetchRepos($pagesResponse);
                 }
             }
         }
     }
     return $this->getImportableProjects();
 }
开发者ID:blazarecki,项目名称:stage1,代码行数:36,代码来源:Discover.php

示例2: configureClientForUser

 /**
  * @param User $user
  *
  * @return Client
  */
 public function configureClientForUser(User $user)
 {
     $accessToken = $user->getProviderAccessToken($this->getName());
     return $this->configureClientForAccessToken($accessToken);
 }
开发者ID:blazarecki,项目名称:stage1,代码行数:10,代码来源:AbstractProvider.php

示例3: setUser

 /**
  * {@inheritDoc}
  */
 public function setUser(User $user)
 {
     $this->user = $user;
     $providerName = $this->getProvider()->getName();
     if (strlen($user->hasProviderAccessToken($providerName))) {
         $this->setAccessToken($user->getProviderAccessToken($providerName));
     }
     return $this;
 }
开发者ID:blazarecki,项目名称:stage1,代码行数:12,代码来源:AbstractImporter.php


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