par
Mike56 » 28 déc. 2012, 21:52
Bonsoir,
j'ai installé à la racine de mon site ZendFrameWork, ensuite, j'ai crée cette page test qui doit me permettre
de lire les derniers commentaires d'une vidéo de youtube tout en pouvant y répondre.
j'ai donc mis le code suivant à cette page:
lien
<?php
// start a new session
session_start();
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
// realpath(APPLICATION_PATH . '/../library'),
realpath('../common/zend/library'),
get_include_path(),
)));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
//AuthSub Functions
function getAuthSubRequestUrl()
{
$next = 'http://www.businessbourse.com/tests.php'; // I have modified this for the sake of this question - it actually has a real url here normally
$scope = 'http://gdata.youtube.com';
$secure = false;
$session = true;
return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);
}
function getAuthSubHttpClient()
{
if (!isset($_GET['token']) ){
echo '<a href="' . getAuthSubRequestUrl() . '">Login!</a>';
return;
} else if (isset($_GET['token'])) {
$_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
}
$httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']);
return $httpClient;
}
// Comment stuff
if($httpClient != '' && isset($_POST['btn_submit']))
{
$comment = $_POST['comment'];
$videoEntry = $yt->getVideoEntry('QQoFLrZ5C3M');
$newComment = $yt->newCommentEntry();
$newComment->content = $yt->newContent()->setText($comment);
// post the comment to the comments feed URL for the video
$commentFeedPostUrl = $videoEntry->getVideoCommentFeedUrl();
$updatedVideoEntry = $yt->insertEntry($newComment, $commentFeedPostUrl,
'Zend_Gdata_YouTube_CommentEntry');
}
// End Comment Stuff
?>
<!DOCTYPE HTML>
<head>
<title>UStream Test</title>
<style>
.comment {
background-color: red;
height: 100px;
width: 500px;
color: white;
font-weight: bold;
}
</style>
</head>
<body>
<div id="wrap">
<div id="authsub">
<?php
if($httpClient == '' && !isset($_GET['token']))
{ ?>
<a href="<?=getAuthSubRequestUrl()?>">Authenticate</a><?php
}
elseif(!isset($_SESSION['sessionToken']) && isset($_GET['token']))
{
$httpClient = getAuthSubHttpClient();
$_SESSION['httpClient'] = $httpClient;
}
else
{
$httpClient = $_SESSION['httpClient'];
echo 'You are authenticated!';
}
// if($httpClient == '') $httpClient = getAuthSubHttpClient();
// if($httpClient == '') echo '<br />empty'; else echo '<br />not empty';
?>
</div><br /><br /><br /><br /><br />
<?php
/*********Creates YouTube Instance***********/
$applicationId = '675765237623';
$clientId = '9873487634985374570t70';
$developerKey = 'AI39si7KdFT8_t4qYHnKViZY5tZ8k2mtumWf6YdGfl3chqEOIkNfBb_jHtb45yYx0PAnf_162kOgQJXVZof4Mi6rn4wXHeCU9g';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$commentFeed = $yt->getVideoCommentFeed('QQoFLrZ5C3M');
/********************************************/
?>
<div id="comment_form">
<form action="http://www.businessbourse.com/tests.php" method="post">
<input type="text" name="comment" placeholder="Enter your comment" />
<input type="submit" name="btn_submit" />
</form>
</div>
<?php
foreach ($commentFeed as $commentEntry) {
echo '<div class="comment">';
echo $commentEntry->title->text . "\n";
echo $commentEntry->content->text . "\n\n\n";
echo '</div><br />';
}
?>
</div>
</body>
Le souci c'est qu'une fois m'être identifié et avoir posté mon commentaire, j'ai ce message d'erreur :
Fatal error: Call to a member function getVideoEntry() on a non-object in /htdocs/public/www/tests.php on line 55
et si je reviens à la page précédente, je trouce ceci:
You are authenticated!
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Argument is not an instance of Zend_Http_Client.' in /htdocs/public/www/Zend/Gdata/YouTube.php:231 Stack trace: #0 /htdocs/public/www/Zend/Gdata/YouTube.php(212): Zend_Gdata_YouTube->setHttpClient(Object(__PHP_Incomplete_Class), '675765237623', '987348763498537...', 'AI39si7KdFT8_t4...') #1 /htdocs/public/www/tests.php(116): Zend_Gdata_YouTube->__construct(Object(__PHP_Incomplete_Class), '675765237623', '987348763498537...', 'AI39si7KdFT8_t4...') #2 {main} thrown in /htdocs/public/www/Zend/Gdata/YouTube.php on line 231
je précise que ce code a été pris ici:
lien2
Si quelqu'un peut m'aider ?
Merci.
Bonsoir,
j'ai installé à la racine de mon site ZendFrameWork, ensuite, j'ai crée cette page test qui doit me permettre
de lire les derniers commentaires d'une vidéo de youtube tout en pouvant y répondre.
j'ai donc mis le code suivant à cette page: [url=http://www.businessbourse.com/tests.php]lien[/url]
[php]<?php
// start a new session
session_start();
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
// realpath(APPLICATION_PATH . '/../library'),
realpath('../common/zend/library'),
get_include_path(),
)));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
//AuthSub Functions
function getAuthSubRequestUrl()
{
$next = 'http://www.businessbourse.com/tests.php'; // I have modified this for the sake of this question - it actually has a real url here normally
$scope = 'http://gdata.youtube.com';
$secure = false;
$session = true;
return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);
}
function getAuthSubHttpClient()
{
if (!isset($_GET['token']) ){
echo '<a href="' . getAuthSubRequestUrl() . '">Login!</a>';
return;
} else if (isset($_GET['token'])) {
$_SESSION['sessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
}
$httpClient = Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']);
return $httpClient;
}
// Comment stuff
if($httpClient != '' && isset($_POST['btn_submit']))
{
$comment = $_POST['comment'];
$videoEntry = $yt->getVideoEntry('QQoFLrZ5C3M');
$newComment = $yt->newCommentEntry();
$newComment->content = $yt->newContent()->setText($comment);
// post the comment to the comments feed URL for the video
$commentFeedPostUrl = $videoEntry->getVideoCommentFeedUrl();
$updatedVideoEntry = $yt->insertEntry($newComment, $commentFeedPostUrl,
'Zend_Gdata_YouTube_CommentEntry');
}
// End Comment Stuff
?>
<!DOCTYPE HTML>
<head>
<title>UStream Test</title>
<style>
.comment {
background-color: red;
height: 100px;
width: 500px;
color: white;
font-weight: bold;
}
</style>
</head>
<body>
<div id="wrap">
<div id="authsub">
<?php
if($httpClient == '' && !isset($_GET['token']))
{ ?>
<a href="<?=getAuthSubRequestUrl()?>">Authenticate</a><?php
}
elseif(!isset($_SESSION['sessionToken']) && isset($_GET['token']))
{
$httpClient = getAuthSubHttpClient();
$_SESSION['httpClient'] = $httpClient;
}
else
{
$httpClient = $_SESSION['httpClient'];
echo 'You are authenticated!';
}
// if($httpClient == '') $httpClient = getAuthSubHttpClient();
// if($httpClient == '') echo '<br />empty'; else echo '<br />not empty';
?>
</div><br /><br /><br /><br /><br />
<?php
/*********Creates YouTube Instance***********/
$applicationId = '675765237623';
$clientId = '9873487634985374570t70';
$developerKey = 'AI39si7KdFT8_t4qYHnKViZY5tZ8k2mtumWf6YdGfl3chqEOIkNfBb_jHtb45yYx0PAnf_162kOgQJXVZof4Mi6rn4wXHeCU9g';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$commentFeed = $yt->getVideoCommentFeed('QQoFLrZ5C3M');
/********************************************/
?>
<div id="comment_form">
<form action="http://www.businessbourse.com/tests.php" method="post">
<input type="text" name="comment" placeholder="Enter your comment" />
<input type="submit" name="btn_submit" />
</form>
</div>
<?php
foreach ($commentFeed as $commentEntry) {
echo '<div class="comment">';
echo $commentEntry->title->text . "\n";
echo $commentEntry->content->text . "\n\n\n";
echo '</div><br />';
}
?>
</div>
</body>[/php]
Le souci c'est qu'une fois m'être identifié et avoir posté mon commentaire, j'ai ce message d'erreur :
[quote]Fatal error: Call to a member function getVideoEntry() on a non-object in /htdocs/public/www/tests.php on line 55[/quote]
et si je reviens à la page précédente, je trouce ceci:
[quote]You are authenticated!
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Argument is not an instance of Zend_Http_Client.' in /htdocs/public/www/Zend/Gdata/YouTube.php:231 Stack trace: #0 /htdocs/public/www/Zend/Gdata/YouTube.php(212): Zend_Gdata_YouTube->setHttpClient(Object(__PHP_Incomplete_Class), '675765237623', '987348763498537...', 'AI39si7KdFT8_t4...') #1 /htdocs/public/www/tests.php(116): Zend_Gdata_YouTube->__construct(Object(__PHP_Incomplete_Class), '675765237623', '987348763498537...', 'AI39si7KdFT8_t4...') #2 {main} thrown in /htdocs/public/www/Zend/Gdata/YouTube.php on line 231[/quote]
je précise que ce code a été pris ici: [url=http://stackoverflow.com/questions/8689944/maintaining-authentication-with-youtube-gdata]lien2[/url]
Si quelqu'un peut m'aider ?
Merci.