$return = array("e" => 1); break; } } } else { //it is a new account switch ($login) { case 0: if ($info["e"]) { //some error, could mean a lot of things, but whichever the case we need to expire all the accounts. $fbh->revokePermissions($at, array()); $return = array("e" => 2); } else { if ($profile_info = $fbh->get('/me?fields=email,location,first_name,last_name,gender,timezone,picture.width(320),verified', $at)) { $fields = array("type" => "fb_acc", "user_id" => $uid, "first_name" => $profile_info['first_name'], "last_name" => $profile_info['last_name'], "email" => $profile_info['email'] ? $profile_info['email'] : '', "gender" => $profile_info['gender'] ? $profile_info['gender'] : '', "location" => $profile_info['location']['name'] ? $profile_info['location']['name'] : '', "verified" => $profile_info['verified'] ? 1 : 0, "access_token" => $at, "expires_at" => $info['expires_at'], "timezone" => $profile_info['timezone'] * 3600, "img" => $profile_info['picture']['data']['url']); $hsc->createFlowProfile($fields, true); $return = array("e" => 0, "l" => $profile_info['location']['name'], "fn" => $profile_info['first_name'], "ln" => $profile_info['last_name'], "em" => $profile_info['email'] ? $profile_info['email'] : '', "ps" => $profile_info['picture']['data']['is_silhouette'], "p" => $profile_info['picture']['data']['url']); } else { $return = array("e" => 4); } } break; case 1: $return = array("e" => 1); break; case 2: $userid = $_SESSION["id"]; $table = "manager_fb_acc"; $condition = " userid=" . $userid; if ($info["e"]) { $fbh->revokePermissions($at, array());
break; case 2: exit(makeBody(1)); break; } } else { //nueva cuenta switch ($login) { case 0: 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['img'] = $credentials->profile_image_url; $fields['name'] = $credentials->name; $fields['location'] = $credentials->location ? $credentials->location : ""; $fields['timezone'] = $credentials->utc_offset; $hsc->createFlowProfile($fields); exit(makebody(0, $fields['name'], $fields['screen_name'], $fields['img'], $credentials->default_profile_image ? "true" : "false", $fields['location'])); } else { $hsc->clearFlow(); exit(makeBody(4)); } } else { $hsc->clearFlow(); exit(makeBody(4)); } break; case 1: $hsc->clearFlow(); exit(makeBody(1)); break; case 2: