exit; } if (isset($_GET['code']) && $_GET['state'] == $_SESSION['btYoutubeNonce'] && !isset($_GET['error'])) { $arrURLInfo = parse_url($dispHTTP . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); $response = $ytObj->getAccessToken($_GET['code'], $arrURLInfo['scheme'] . "://" . $arrURLInfo['host'] . $arrURLInfo['path']); if (isset($response['access_token'])) { $ytObj->accessToken = $response['access_token']; $ytObj->refreshToken = $response['refresh_token']; $channelInfo = $ytObj->getChannelInfo(); $channelSnippet = $ytObj->getChannelInfo("snippet"); $channelStats = $ytObj->getChannelInfo("statistics"); // Add User $arrColumns = array("member_id", "channel_id", "uploads_id", "thumbnail", "access_token", "refresh_token", "lastupdate", "subscribers", "title", "videocount", "viewcount", "loginhash"); $arrValues = array($memberInfo['member_id'], $channelInfo['items'][0]['id'], $channelInfo['items'][0]['contentDetails']['relatedPlaylists']['uploads'], $channelSnippet['items'][0]['snippet']['thumbnails']['medium']['url'], $response['access_token'], $response['refresh_token'], time(), $channelStats['items'][0]['statistics']['subscriberCount'], $channelSnippet['items'][0]['snippet']['title'], $channelStats['items'][0]['statistics']['videoCount'], $channelStats['items'][0]['statistics']['viewCount'], md5($channelInfo['items'][0]['id'])); $ytObj->addNew($arrColumns, $arrValues); $ytObj->updateVideos(); echo "\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "members/console.php?cID=" . $cID . "';\n\t\t\t\t\t</script>\n\t\t\t\t"; exit; } else { echo "\n\t\t\t\t\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\twindow.location = '" . $MAIN_ROOT . "members/console.php?cID=" . $cID . "&error=1';\n\t\t\t\t\t</script>\n\t\t\t\t\t\n\t\t\t\t"; exit; } } elseif (isset($_GET['error'])) { $countErrors++; $dispError = "Unable to connect to Youtube! Please try again."; } elseif (!isset($_GET['error']) && !isset($_GET['code'])) { $loginLink = $ytObj->getConnectLink($dispHTTP . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); $_SESSION['btYoutubeNonce'] = $ytObj->tokenNonce; echo "\n\t\t\t\n\t\t\t\t<p class='main'>Redirecting to Youtube...</p>\n\t\t\t\t\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\twindow.location = '" . $loginLink . "';\n\t\t\t\t</script>\n\t\t\t\n\t\t\t"; exit; }