| Server IP : 103.82.32.14 / Your IP : 216.73.217.121 Web Server : Apache/2.2.32 (Unix) mod_ssl/2.2.32 OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 System : Linux cloud.lonmanhoabinh.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : lonmakmf ( 524) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/musicyzf/public_html/ |
Upload File : |
<?php
session_start();
if(isset($_REQUEST['setting']))
{
if(isset($_REQUEST['OAUTH2_CLIENT_ID']))
{
$list = array('OAUTH2_CLIENT_ID' => $_REQUEST['OAUTH2_CLIENT_ID'], 'OAUTH2_CLIENT_SECRET' => $_REQUEST['OAUTH2_CLIENT_SECRET']);
$json = json_encode($list);
file_put_contents('auth_get_key_kien.txt', $json);
echo 'Thiết lập thành công';
}
?>
<form method="POST" action="http://music.camcaophong.biz/get_key_kien.php?setting">
CLIENT ID <input type="text" name="OAUTH2_CLIENT_ID"/><br/>
CLIENT SECRET <input type="text" name="OAUTH2_CLIENT_SECRET"/><br/>
<input type="submit" value="Gửi"/>
</form>
<?php
}
else
{
$list = json_decode(file_get_contents('auth_get_key_kien.txt'), true);
require_once dirname(__FILE__).'/GoogleClientApi/Google_Client.php';
require_once dirname(__FILE__).'/GoogleClientApi/contrib/Google_YouTubeService.php';
$OAUTH2_CLIENT_ID = $list['OAUTH2_CLIENT_ID']; // Enter your Client ID here
$OAUTH2_CLIENT_SECRET = $list['OAUTH2_CLIENT_SECRET']; // Enter your Client Secret here
$REDIRECT = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], FILTER_SANITIZE_URL);
$APPNAME = "Trinh Lam Tool 2";
$client = new Google_Client();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->setScopes(array('https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.force-ssl',
'https://www.googleapis.com/auth/youtube.readonly',
'https://www.googleapis.com/auth/youtube.upload',
'https://www.googleapis.com/auth/youtubepartner',
'https://www.googleapis.com/auth/youtubepartner-channel-audit'));
$client->setRedirectUri($REDIRECT);
$client->setApplicationName($APPNAME);
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
$service = new Google_YouTubeService($client);
if (isset($_GET['code'])) {
if (strval($_SESSION['state']) !== strval($_GET['state'])) {
die('The session state did not match.');
}
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
}
if (isset($_SESSION['token']) && !isset($_REQUEST['load'])) {
$client->setAccessToken($_SESSION['token']);
$list_json = json_decode($_SESSION['token']);
$list = array(
'ClientId' => $list['OAUTH2_CLIENT_ID'],
'ClientSecret' => $list['OAUTH2_CLIENT_SECRET'],
'AccessToken' => $list_json->access_token,
'RefreshToken' => $list_json->refresh_token
);
echo "<textarea style='width: 500px; height: 400px;'>" . json_encode($list) . "</textarea>";
}
// Check to ensure that the access token was successfully acquired.
if ($client->getAccessToken()) {
try {
// Call the channels.list method to retrieve information about the
// currently authenticated user's channel.
$channelsResponse = $youtube->channels->listChannels('contentDetails', array('mine' => 'true'));
$htmlBody = '';
foreach ($channelsResponse['items'] as $channel) {
// Extract the unique playlist ID that identifies the list of videos
// uploaded to the channel, and then call the playlistItems.list method
// to retrieve that list.
$uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads'];
$playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
'playlistId' => $uploadsListId,
'maxResults' => 50
));
$htmlBody .= "<h3>Videos in list $uploadsListId</h3><ul>";
foreach ($playlistItemsResponse['items'] as $playlistItem) {
$htmlBody .= sprintf('<li>%s (%s)</li>', $playlistItem['snippet']['title'],
$playlistItem['snippet']['resourceId']['videoId']);
}
$htmlBody .= '</ul>';
}
} catch (Google_ServiceException $e) {
$htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>',
htmlspecialchars($e->getMessage()));
} catch (Google_Exception $e) {
$htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>',
htmlspecialchars($e->getMessage()));
}
echo $htmlBody;
$_SESSION['token'] = $client->getAccessToken();
} else {
$state = mt_rand();
$client->setState($state);
$_SESSION['state'] = $state;
$authUrl = $client->createAuthUrl();
header("Location: $authUrl"); /* Redirect browser */
exit();
}
}
?>