Bonjour,

j'ai installé Zend framework à la racine de mon site et j'ai utlisé le code ci-dessous afin d'ajouter un commentaire à une vidéo youtube à partir de mon site en s'authentifiant:

Lien de la page test :http://www.businessbourse.com/tests.php

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?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 = 'applicationId';
    $clientId = 'clientId';
    $developerKey = 'AI39si6gCxCr6_xpjjDcgH7YkrlrfvHajRCyHdPex7C4RGWAUXc7CJcBBMLqHEoW__I5QGcPgyP7nvATmCojhRNrZ4eK3HZKcA';
    $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 :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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!


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 j'ai emprunté ce code ici: http://stackoverflow.com/questions/8...-youtube-gdata

Si quelqu'un peut m'aider ?

Merci.