Beispiel #1
0
 /**
  * Authorize process for connector
  *
  * @param ConnectorInterface $connector
  */
 protected function authConnector(ConnectorInterface $connector)
 {
     $clientId = $this->readline("Enter Client ID: ");
     $clientSecret = $this->readline("Enter Client Secret: ");
     $redirectUrl = $this->readline("Enter redirect URL: ");
     if ($connector->getOauthType() === 'oauth2') {
         $scopes = $this->readline("Enter scopes (optional): ");
         if ($scopes !== '') {
             $scopes = explode(',', str_replace(' ', '', $scopes));
         }
     } else {
         $scopes = [];
     }
     $params = ['client_key' => $clientId, 'client_secret' => $clientSecret, 'redirect_url' => $redirectUrl, 'scopes' => $scopes];
     try {
         $response = $this->connectorService->requestToken($connector, $params);
         $token = $response->request_token;
         $request = $this->getTokenRequest($connector, $token->request_url);
         if ($connector->getOauthType() === 'oauth1') {
             $params['temp_identifier'] = $token->temp_identifier;
             $params['temp_secret'] = $token->temp_secret;
             $params['oauth_token'] = $request->query->get('oauth_token');
             $params['oauth_verifier'] = $request->query->get('oauth_verifier');
             $auth = $this->connectorService->authorizeToken($connector, $params);
             $this->output("Your access token is: {$auth->token->access_token}");
             $this->output("Your access token secret is : {$auth->token->access_token_secret}");
         } else {
             $params['code'] = $request->query->get('code');
             $auth = $this->connectorService->authorizeToken($connector, $params);
             $this->output("Your access token is: {$auth->token->access_token}");
         }
     } catch (\Exception $ex) {
         $this->output("ERROR: {$ex->getMessage()}");
     }
 }
Beispiel #2
0
 /**
  * Setup report connectors
  */
 protected function setupConnectors()
 {
     $connectors = $this->connectorService->getConnectors();
     $this->report->setConnectors($connectors);
     $openConnector = $this->connectorService->buildOpenConnector();
     $this->report->setOpenConnector($openConnector);
     $this->report->setSentiment(new Sentiment());
     $this->report->setSpelling(new Spelling());
 }