use OneAManager\Handler_NewSocialConnection; $login = $_GET['state'] ? $_GET['state'] : 0; switch ($login) { case 0: $fcn = "rg_twa_cb({e:4,n:'',sn:'',i:''})"; break; case 1: $fcn = "lg_twa_cb(4)"; break; case 2: $fcn = "ap_twa_cb({e:4,n:'',sn:'',i:''})"; break; } error_log("Log is {$login}"); try { if ($htw = new Handler_Twitter()) { if ($callback = $htw->generateOAuth('http://apreciodepana.com/fcn/f_manager/c_add_tw_alt.php?state=' . $login)) { $hsc = new Handler_NewSocialConnection(); $hsc->startTwitterFlow(true, $callback['oauth_token'], $callback['oauth_token_secret']); header('location:' . $callback['url']); exit; } else { header("location:http://apreciodepana.com/redes.php?tipo=1&add_tw=4"); exit; } } else { header("location:http://apreciodepana.com/redes.php?tipo=1&add_tw=4"); exit; } } catch (Exception $e) { header("location:http://apreciodepana.com/redes.php?tipo=1&add_tw=4");
$table = "manager_tw_acc"; $condition = " user_id=" . $access_token["user_id"]; if ($result = $db->doSingleSelect($table, $condition)) { error_log($result); //cuenta pertenece a otro usuario header("location:http://apreciodepana.com/redes.php?tipo=1&add_tw=1"); } else { //nueva cuenta $hsc->clearFlow(); $userid = $_SESSION["id"]; $table = "manager_tw_acc"; $condition = " userid=" . $userid; if ($result = $db->doSingleSelect($table, $condition)) { $return = array("e" => 5); } else { if ($htw = new Handler_Twitter($access_token['oauth_token'], $access_token['oauth_token_secret'])) { if ($credentials = $htw->genericGet("account/verify_credentials", array("include_entities" => "false", "skip_status" => 1))) { $fields['userid'] = $userid; $fields['img'] = $credentials->profile_image_url; $fields['name'] = $credentials->name; $fields['location'] = $credentials->location ? $credentials->location : ""; $fields['timezone'] = $credentials->utc_offset; unset($fields['type']); $table = "manager_tw_acc"; if ($db->doInsert($table, $fields)) { $hsc->clearFlow(); header("location:http://apreciodepana.com/redes.php?tipo=1&add_tw=0"); } else { header("location:http://apreciodepana.com/redes.php?tipo=1&add_tw=6"); } }