PHP Curl and Loop based on a numeric value
        Posted  
        
            by danit
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by danit
        
        
        
        Published on 2010-03-30T18:37:23Z
        Indexed on 
            2010/06/10
            12:02 UTC
        
        
        Read the original article
        Hit count: 425
        
Im using the Twitter API to collect the number of tweets I've favorited, well to be accurate the total pages of favorited tweets.
I use this URL: http://api.twitter.com/1/users/show/username.xml
I grab the XML element 'favorites_count'
For this example lets assume favorites_count=5
The Twitter API uses this URL to get the favorties: http://twitter.com/favorites.xml (Must be authenticated)
You can only get the last 20 favorties using this URL, however you can alter the URL to include a 'page' option by adding: ?page=3 to the end of the favorites URL e.g.
http://twitter.com/favorites.xml?page=2
So what I need to do is use CURL (I think) to collect the favorite tweets, but using the URL:
http://twitter.com/favorites.xml?page=1
http://twitter.com/favorites.xml?page=2
http://twitter.com/favorites.xml?page=3
http://twitter.com/favorites.xml?page=4
etc...
Some kind of loop to visit each URL, and collect the Tweets and then output the cotents.
Can anyone help with this: - Need to use CURL to authenticate - Collect the number of pages of tweets (Already scripted this) - Then use a loop to go through each page URL based on the pages value?
© Stack Overflow or respective owner