【发布时间】:2012-11-15 20:44:27
【问题描述】:
我正在尝试通过entities 参数获取并显示在推文中发布的图像。我的 url 中有 include_entities,可以看到返回的 json 中的实体。
在我的 foreach 循环中,我正在执行以下操作:
foreach($results as $result){
$media_url = $result->entities->media->media_url;
$media_size_h = $result->entities->media->sizes->small->h;
$media_size_w = $result->entities->media->sizes->small->w;
...
}
但是,这并没有返回任何内容。
对于我的输出,我有...
if(strlen($media_url) > 0)
{
//format table for tweets with images
} else {
//format table for regular tweets
}
这是 json...
array(20) {
[0]=>
object(stdClass)#5 (21) {
...
["entities"]=>
object(stdClass)#7 (4) {
["media"]=>
array(1) {
[0]=>
object(stdClass)#8 (10) {
["type"]=>
string(5) "photo"
["media_url"]=>
string(38) "http://photourl.jpg"
...
["sizes"]=>
object(stdClass)#9 (4) {
["thumb"]=>
object(stdClass)#10 (3) {
["resize"]=>
string(4) "crop"
["h"]=>
int(150)
["w"]=>
int(150)
}
...
}
任何想法为什么这不起作用?任何帮助将非常感激!
【问题讨论】:
标签: php image twitter entities