Php disqs游标-尝试获取非对象的属性
我参考了这些链接,并了解如何检索Disqs评论 但我一直在得到这些Php disqs游标-尝试获取非对象的属性,php,disqus,Php,Disqus,我参考了这些链接,并了解如何检索Disqs评论 但我一直在得到这些 (i) PHP注意:未定义变量:光标位于第13行 (二)PHP注意事项:第48行尝试获取非object的属性 下面是PHP脚本: <?php ini_set('display_errors', 'on'); $key="API_SECRET_KEY"; $forum="tocsg"; $thread = 'link:http://www.theonlinecitizen.com/2015/10/how-far-can-pi
(i) PHP注意:未定义变量:光标位于第13行
(二)PHP注意事项:第48行尝试获取非object的属性 下面是PHP脚本:
<?php
ini_set('display_errors', 'on');
$key="API_SECRET_KEY";
$forum="tocsg";
$thread = 'link:http://www.theonlinecitizen.com/2015/10/how-far-can-pigs-fly/';
$limit = '100';
$endpoint = 'http://disqus.com/api/3.0/threads/listPosts.json?api_secret='.urlencode($key).'&forum='.$forum.'&limit='.$limit.'&thread='.$thread;
//$cursor=null;
$j=0;
listcomments($endpoint,$cursor,$j);
function listcomments($endpoint,$cursor,$j) {
// Standard CURL
$session = curl_init($endpoint.$cursor);
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($session);
curl_close($session);
// Decode JSON data
$results = json_decode($data);
if ($results === NULL) die('Error parsing json');
// Comment response
$comments = $results->response;
// Cursor for pagination
$cursor = '&cursor=' . $results->cursor->next;
$i=0;
foreach ($comments as $comment) {
$name = $comment->author->name;
$created = $comment->createdAt;
$comment = $comment->message;
// Get more data...
echo "<p>".$name." wrote:<br/>";
echo $comment."<br/>";
echo $created."<br />";
$i++;
}
// cursor through until today
if ($i == 100) {
$cursor = $cursor->next;
$i = 0;
listcomments($endpoint,$cursor,$j);
/* uncomment to only run $j number of iterations
$j++;
if ($j < 10) {
listcomments($endpoint,$cursor,$j);
}*/
}
}
?>
我尝试使用$cursor=null;解决第一个错误。但第二个错误仍然存在。提前谢谢。您使用的是
$cursor='&cursor='$结果->光标->下一步
并尝试从$cursor=$cursor->next获取下一步代码>
在第31行试试这个:
$cursor = $results->cursor->next;
或第48行的此项
$cursor = $results->cursor->next;
使用$cursor='&cursor='$结果->光标->下一步
并尝试从$cursor=$cursor->next获取下一步代码>
在第31行试试这个:
$cursor = $results->cursor->next;
或第48行的此项
$cursor = $results->cursor->next;
我想你需要检查hasNext是否为真。否则,您正在寻找不存在的下一个。我想您需要检查hasNext是否为真。否则,您将寻找不存在的下一个。