/** * Sets the appropriate Twitter API access token using * a given Twitter Profile * * @param TwitterProfile $profile * * @return TwitterService */ public function setAccessTokenFromProfile(TwitterProfile $profile) { $tokens = $profile->get(['access_token', 'access_token_secret']); if (!empty($tokens['access_token'])) { $this->app['twitter']->setTokens($tokens['access_token'], $tokens['access_token_secret']); $this->profile = $profile; } else { // use the access token from profile that referenced this profile $referencingProfile = $profile->relation('most_recently_referenced_by'); // recursion would be nice here, but could be dangerous $tokens = $referencingProfile->get(['access_token', 'access_token_secret']); if ($referencingProfile->exists() && !empty($tokens['access_token'])) { $this->app['twitter']->setTokens($tokens['access_token'], $tokens['access_token_secret']); $this->profile = $referencingProfile; } } return $this; }
public function finishSignup($req, $res) { $params = ['title' => 'Finish Signup', 'userEmail' => $req->request('user_email'), 'username_post' => $req->request('username')]; if ($fbid = $req->session('fbid')) { $profile = new FacebookProfile($fbid); $profile->load(); $params['profileUrl'] = $profile->url(); $params['profilePic'] = $profile->profilePicture(); $params['username'] = $profile->username; } elseif ($tid = $req->session('tid')) { $profile = new TwitterProfile($tid); $profile->load(); $params['profileUrl'] = $profile->url(); $params['profilePic'] = $profile->profilePicture(); $params['username'] = $profile->username; } elseif ($iid = $req->session('iid')) { $profile = new InstagramProfile($iid); $profile->load(); $params['profileUrl'] = $profile->url(); $params['profilePic'] = $profile->profilePicture(); $params['username'] = $profile->username; } else { return $res->setCode(404); } $params['username'] = preg_replace('/[^a-z0-9]+/i', '', $params['username']); return new View('finishSignup', $params); }
public function refreshProfiles() { return TwitterProfile::refreshProfiles(); }