當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。