public function login() { $uid = $this->session->user->id; $token = md5(date('Ymd') . $this->session->user->id . $this->session->user->login . $this->session->user->login . 'HAHAAHAVOACABARCOMISSOJAJA'); $v = new Views(); $v->username = $this->session->user->login; $v->link = HOST . "meu-perfil/redes-sociais/nerdtrack/callback/?uid={$uid}&token={$token}"; $message = $v->render('mail/nerdtrack-link-account.phtml'); Phalanx::loadExtension('phpmailer'); $mail = new PHPMailer(true); $mail->IsSMTP(); $mail_status = true; try { $mail->AddReplyTo(MAIL_FROM, MAIL_ALIAS); $mail->AddAddress($this->post->email_address, $this->session->user->login); $mail->Subject = 'SkyNerd: VĂnculo de conta da Nerdtrack'; $mail->MsgHTML($message); $mail->Send(); } catch (phpmailerException $e) { $mail_status = false; } header("Content-type: text/html; charset=utf-8"); if ($mail_status) { Phalanx::loadClasses('SocialNetwork'); SocialNetwork::link_account($this->session->user->id, NERDTRACK, $this->post->email_address, false); die('SUCCESS'); } else { die('FAIL'); } }
public function callback() { Phalanx::loadClasses('SocialNetwork'); $instagram = new Instagram($this->config); $instagram->setAccessCode(Request::get()->code); $access_token = $instagram->getOauthToken(); $Session = new Session(); SocialNetwork::link_account($Session->user->id, INSTAGRAM, $access_token); Request::redirect(HOST . 'perfil/configuracoes'); }
public function callback() { Phalanx::loadClasses('Youtube'); $query_str = parse_url(Request::get()->variables); parse_str($query_str['query'], $oAuthResponse); $token = $oAuthResponse['token']; $tokens = new stdClass(); $tokens->temporary = $token; $tokens->permanent = $this->exchangeToken($token); $youtube = new Youtube($tokens->permanent); $tokens->username = $youtube->username; Phalanx::loadClasses('SocialNetwork'); SocialNetwork::link_account($this->session->user->id, YOUTUBE, $tokens); Request::redirect(HOST . 'perfil/configuracoes'); }
public function callback() { Phalanx::loadClasses('twitteroauth'); $connection = new TwitterOAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, $this->session->oauth_token, $this->session->oauth_token_secret); $access_token = $connection->getAccessToken($this->get->oauth_verifier); $this->session->access_token = $access_token; $this->session->destroy('oauth_token'); $this->session->destroy('oauth_token_secret'); if ($connection->http_code == 200) { $this->session->twitter_status = 'verified'; Phalanx::loadClasses('SocialNetwork'); SocialNetwork::link_account($this->session->user->id, TWITTER, $access_token); Request::redirect(HOST . 'perfil/configuracoes/'); } }
public function callback() { $facebook = new Facebook(array('appId' => FACEBOOK_APPID, 'secret' => FACEBOOK_SECRET, 'cookie' => true)); #Recebo o token inicial, short-lived, de 2hrs $facebook = new Facebook(array('appId' => FACEBOOK_APPID, 'secret' => FACEBOOK_SECRET, 'cookie' => true)); $facebook->setAccessToken($facebook->getAccessToken()); #Trocamos o token short-lived por uma long lived $facebook->setExtendedAccessToken(); $extendedAccessToken = $_SESSION["fb_" . FACEBOOK_APPID . "_access_token"]; $facebook->setAccessToken($extendedAccessToken); $accessToken = $facebook->getAccessToken(); # agora eu pego uns dados do cara $me = $facebook->api('/me'); # e guardo o token c/ mais uns dados dele $o = new stdClass(); $o->accessToken = $accessToken; $o->userID = $me['id']; $o->userName = $me['username']; SocialNetwork::link_account($this->session->user->id, SocialNetwork::FACEBOOK, $o); Request::redirect(HOST . 'perfil/configuracoes'); }