$youtube = new Google_YoutubeService($client);
//update Playlist Name here
$ListOb = new $youtube->$Google_Playlist();
$ListOb.setId($item['id']);
$InSnip = new $youtube->Google_PlaylistSnippet();
$InSnip.setChannelId($item['id']);
$InSnip.setTitle(str_replace("Candidates Federal","Candidates Australian Federal",$title));
$ListOb.setSnippet($InSnip);
ASKER
ASKER
that is line 2 in your example above julianH)Doesn't make sense if it is
ASKER
<?php
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_YouTubeService.php';
require_once '../StdPHPErrors.php';
// Set your cached access token. Remember to replace $_SESSION with a
// real database or memcached.
session_start();
$client = new Google_Client();
$model = new Google_Model();
$client->setApplicationName('xxxx');
//xxxxxVideo Uploader ID stuff
$client->setClientId('xxxxxx);
$client->setClientSecret('xxxx');
$client->setRedirectUri('http://127.0.0.1:8080/YoutubeAPI/youtube.php');
//$client->setDeveloperKey('xxxxx'); // Server Key
$client->setDeveloperKey('xxxxx'); //Browser Key
/*
//xxx.xxx-xx ID stuff
$client->setClientId('xxxx.apps.googleusercontent.com');
$client->setClientSecret('xxxx-');
$client->setRedirectUri('xxxx');
$client->setDeveloperKey('xxxxx');
*/
$youtube = new Google_YoutubeService($client);
//unset($_SESSION);
if (isset($_GET['code'])) {
echo1("1");
$client->authenticate();
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
//echo1("2");
$client->setAccessToken($_SESSION['token']);
}
$htmlBody = '';
if ($client->getAccessToken()) {
//echo1("3");
try {
//echo1("3a");
$playlists_optParams = array('mine' => 'true','maxResults' => '50');
$playlistItems = $youtube->playlists->listPlaylists('snippet',$playlists_optParams);
$htmlBody .= '<table>';
$htmlBody .= '<tr><th>Title</th><th>Change Req</th><th>Changed?</th></tr>';
foreach ($playlistItems['items'] as $item) {
//print_r1($item);
//$htmlBody .= "<li>".$item['snippet']['title']." ID:".$item['id']."</li>";
$htmlBody .= '<tr>';
$title = $item['snippet']['title'];
$id = $item['id'];
$htmlBody .= '<td>'.$title.'</td>';
if(!strstr($title,"Australian") && strstr($title, "Senate")) {
$htmlBody .= '<td>Yes</td>';
//update Playlist Name here
$ListOb = new $youtube->Google_Playlist();
$ListOb.setId($item['id']);
$InSnip = new $youtube->Google_PlaylistSnippet();
$InSnip.setChannelId($item['id']);
$InSnip.setTitle(str_replace("Candidates Federal","Candidates Australian Federal",$title));
$ListOb.setSnippet($InSnip);
$playlistUpdate = $youtube->playlists->update('snippet',$ListOb);
//error with update
$htmlBody .= '<td class="bad">No</td>';
//successful update
$htmlBody .= '<td class="good">Yes</td>';
} else {
$htmlBody .= '<td>No</td>';
}
$htmlBody .= '</tr>';
} //end for each item in Playlist
$htmlBody .= '</table>';
} 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()));
}
$_SESSION['token'] = $client->getAccessToken();
} else {
echo1("4");
echo1("5");
$state = mt_rand();
$client->setState($state);
$_SESSION['state'] = $state;
$authUrl = $client->createAuthUrl();
$htmlBody = <<<END
<h3>Authorization Required</h3>
<p>You need to <a href="$authUrl">authorize access</a> before proceeding.<p>
END;
}
?>
<!doctype html>
<html>
<head>
<title>My Uploads</title>
<style>
table tr td { border: 1pt black solid; }
.bad {color:red;}
.good {color:green;}
</style>
</head>
<body>
<h1>Youtube Project Output:</h1>
<?php print $htmlBody;
echo1("<br /> Complete:".date("H:i:s"));
?>
</body>
</html>
$ListOb = new $youtube->Google_Playlist();
Which is not the same as Line 2 of my post$ListOb = new Google_Playlist();
Note the absence of the $youtube-> prefix in the second line of code.ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
Open in new window