Piwik\Plugins\Marketplace\Api\Service::authenticate PHP Method

authenticate() public method

public authenticate ( $accessToken )
    public function authenticate($accessToken)
    {
        if (empty($accessToken)) {
            $this->accessToken = null;
        } elseif (ctype_alnum($accessToken)) {
            $this->accessToken = $accessToken;
        }
    }

Usage Example

示例#1
0
文件: API.php 项目: piwik/piwik
 /**
  * Saves the given license key in case the key is actually valid (exists on the Piwik Marketplace and is not
  * yet expired).
  *
  * @param string $licenseKey
  * @return bool
  *
  * @throws Exception In case of an invalid license key
  * @throws Service\Exception In case of any network problems
  */
 public function saveLicenseKey($licenseKey)
 {
     Piwik::checkUserHasSuperUserAccess();
     $licenseKey = trim($licenseKey);
     // we are currently using the Marketplace service directly to 1) change LicenseKey and 2) not use any cache
     $this->marketplaceService->authenticate($licenseKey);
     try {
         $consumer = $this->marketplaceService->fetch('consumer/validate', array());
     } catch (Api\Service\Exception $e) {
         if ($e->getCode() === Api\Service\Exception::HTTP_ERROR) {
             throw $e;
         }
         $consumer = array();
     }
     if (empty($consumer['isValid'])) {
         throw new Exception(Piwik::translate('Marketplace_ExceptionLinceseKeyIsNotValid'));
     }
     $this->setLicenseKey($licenseKey);
     return true;
 }
All Usage Examples Of Piwik\Plugins\Marketplace\Api\Service::authenticate