/** * Prepare the OAuth client before sending a request * * @param string $provider_id * @throws \Exception */ protected function prepareRequest($provider_id) { $userProvider = $this->providerRepository->get($provider_id); if (empty($userProvider['token'])) { throw new \Exception('Invalid access token'); } $this->token = $userProvider['token']; }
/** * POST: / * * @return redirect(/) */ public function postIndex() { $user = Auth::user(); $message = Input::get('message'); $services = Input::get('services'); foreach ($services as $providerId => $serviceEnabled) { $bIsEnabled = (bool) $serviceEnabled; if ($bIsEnabled === true) { $provider = $this->providerRepository->get($providerId); $post = $this->postRepository->createMessage($provider, $message); $this->dispatch(new PublishMessage($post)); } } return redirect('/'); }
/** * Prepare the Twitter client before sending a request * Reads the oauth token and secret from the Provider for Twitter authentication * * @param string $provider_id * @throws \Exception */ protected function prepareRequest($provider_id) { $userProvider = $this->providerRepository->get($provider_id); if (empty($userProvider['oauth_token']) || empty($userProvider['oauth_token_secret'])) { throw new \Exception('Invalid access token'); } $this->client->setOauthToken($userProvider['oauth_token'], $userProvider['oauth_token_secret']); }