[英]Facebook PHP Api suddenly not working
<?php
//get token
$access_token = $facebook->getAccessToken();
$albumCover = $facebook->api("/". $album_id ."?fields=picture", "get");
//echo $albumCover['picture']['data']['url'];
//echo '<pre>';
//print_r($albumCover);
//echo '</pre>';
?>
<div class="fb-album<?php if ($counter % 5 == 0){echo ' no-right';}; ?>">
<a href="<?php the_permalink(); ?>">
<div style="width:160px; height:100px; overflow:hidden;">
<img width="160px" src="<?php echo $albumCover['picture']['data']['url']; ?>" />
</div>
</a>
<p><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></p>
</div>
突然之间,这行不通,并且没有返回错误,有人可以帮我一下吗?
谢谢
更新:
找到了答案,看来我再也无法使用?fields = picture访问每张专辑的封面照片,我不得不使用?fields = cover_photo并深入研究该数组,这是我的解决方案,感谢您的所有支持
<?php
//get token
$access_token = $facebook->getAccessToken();
$albumCover = $facebook->api("/". $album_id ."?fields=cover_photo", "get");
//echo $albumCover['picture']['data']['url'];
$albumCover2 = $facebook->api("/". $albumCover['cover_photo'] ."?fields=picture", "get");
//echo '<pre>';
//print_r($albumCover2);
//echo '</pre>';
?>
<div class="fb-album<?php if ($counter % 5 == 0){echo ' no-right';}; ?>">
<a href="<?php the_permalink(); ?>">
<div style="width:160px; height:100px; overflow:hidden;">
<img width="160px" src="<?php echo $albumCover2['picture']; ?>" />
</div>
</a>
<p><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></p>
</div>
我为格式表示歉意,很难在此编辑器中使它看起来正确
每当Facebook API无法获取数据或无法正常工作时,
它在PHP的错误日志中记录错误。 检查您的PHP错误日志。
今天有一个重大的变化发布; 值得查看发行说明以了解您可能受到的影响。 大概是因为隐私的改变...
您还需要在getAccessToken之后使用setAccessToken方法。
$access_token = $facebook->getAccessToken();
$facebook->setAccessToken($access_token);
根据您在评论中发布的错误消息,
如果活动索引不存在,则会收到通知错误mod_fcgid
。 为了避免这种情况,您可以检查该索引是否已设置/存在。
码:
if($blah['active']=="something"){foo();}
应该:
码:
if(isset($blah['active']) && $blah['active']=="something"){foo();}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.