2013-05-01 48 views
0

我尝试在YouTube上使用API​​ Eden。Youtube API使用Eden PHP库

http://www.eden-php.com/documentation/social/google/youtube

我阻止了连接。我使用此代码类似thez说:

session_start(); 

$auth = eden('google')->auth('[CLIENT_ID]', '[CLIENT_SECRET]', 'http://yourwebsite.com/auth', '[API_KEY]'); 

//if no code and no session 
if(!isset($_GET['code']) && !isset($_SESSION['token'])) { 
    //redirect to login 
    $login = $auth->getLoginUrl('youtube'); 
    header('Location: '.$login); 
    exit; 
} 

//Code is returned back from google 
if(isset($_GET['code'])) { 
    //save it to session 
    $access = $auth->getAccess($_GET['code']); 
    $_SESSION['token'] = $access['access_token']; 

} 

我必须把我的dev键,身份证,id_secret ...

但是,当我走在新页面上,并尝试放这段代码那样:

session_start(); 

include('eden.php'); 


$youtube = eden('google')->youtube($_SESSION['token'], '[DEVELOPER_KEY]'); 

页眉:

new.php?code=4/wDGcl_A2FePVDPGE42s4p1qGH-mI.wmD1IpIt-OIVOl05ti8ZT3ZN-xDDfAI 

我:

Notice: Undefined index: token in C:\wamp\www\eden\new.php on line 6 

回答

0

您正在使用的库似乎没有使用严格标准设计,并且您的PHP设置非常严格,请尝试在代码最顶端添加error_reporting(E_ALL^(E_NOTICE | E_WARNING));以禁用通知和警告。 问题在于脚本正在尝试访问索引为“index”的数组,而不检查它是否先存在。

+0

Thx!错误说我忘了在Wamp中激活php_curl。现在是工作。 – mpgn 2013-05-01 19:33:25