仅获取用户的Twitter照片流

仅获取用户的Twitter照片流,twitter,Twitter,我正在尝试获取一个JSON格式的列表,其中包含一个用户在Twitter上发布的所有照片 我有下面的URL,但这也给用户带来了正常的帖子 https://api.twitter.com/1/statuses/user_timeline/adrianfraguela.json?include_entities=t&count=1&callback=? 我如何才能只获取他们的照片?我使用以下PHP实现了这一点。我已经在大多数行中添加了注释,以便易于理解 <?php //sett

我正在尝试获取一个JSON格式的列表,其中包含一个用户在Twitter上发布的所有照片

我有下面的URL,但这也给用户带来了正常的帖子

https://api.twitter.com/1/statuses/user_timeline/adrianfraguela.json?include_entities=t&count=1&callback=?

我如何才能只获取他们的照片?

我使用以下PHP实现了这一点。我已经在大多数行中添加了注释,以便易于理解

<?php
//setting up variables to use with 
    $twitterUsername = 'someUser';
    $jsonURL = 'https://api.twitter.com/1/statuses/user_timeline/'.$twitterUsername.'.json?include_entities=t&count=50&callback=?';
    $json = file_get_contents($jsonURL, true); //getting the file content           
    $decode = json_decode($json, true); //create array of contents
    $counter = 0; //set up a counter so we can count the number of iterations
    $howMany = 7; //how many images we would like to return

    foreach($decode as $val) {
        $counter ++;
        $checkMedia = $val["entities"]["media"][0]; //select the branch we want to work with

            if ((is_array($checkMedia)) && array_key_exists("media_url", $checkMedia)) { //check to see if the array has a media url if so continue
                $url = $checkMedia["media_url"];//url of the image
                $picText = $val["text"];//text to go with the image

                $picText = strip_tags($picText); ?>

                <a href="<?php echo $url; ?>"><img src="<?php echo $url; ?>" alt="<?php echo $picText; ?>" title="<?php echo $picText; ?>" /></a>

                <?php if ($counter == $howMany) {break;} //break out of loop after x iterations

            }

    } ?>