How to access Tumblr API Photo Data Feed (i.e. all

2020-05-05 16:49发布

问题:

I am currently developing a project in PHP that connects to Tumblr photo blogs via Tumblr API with my api-key to access posted photos in specified Tumblr photo blog.

I used the Tumblr API documentation to get started and have cross-referenced many web sites (including this one) and books, and have managed to "hack"/piece together a program that retrieves the Tumblr photos from specified blog.

I have successfully connected and retrieved photos by parsing the array with multiple foreach & if-else control-flow statements, and then placing the URLs retrieved of each photo in an array for later processing.

However, no matter which Tumblr blog I connect to and retrieve photos from, there are only 19 photos retrieved in the array of URLs for each Tumblr blog - and I would like to retrieve all of them.

I know that Tumblr loads a few images at a time, and then more pictures are loaded either by clicking "next/previous/older" and/or infinite scrolling down to load more images (especially in the archive).

Here is the example URL with api-key I use to connect to Tumblr: http://api.tumblr.com/v2/blog/EXAMPLEBLOG.tumblr.com/posts/photo?api_key=API-KEY-NUMBER"

So my question(s) are:

1.) Is there way to access all the posts/photos with just one API call as per above? (I have tried to EXAMPLEBLOG.tumblr.com/archive, but this retrieves nothing.)

2.) Is there any way to access the entire Tumblr photo archive?

Thanks for any help you can offer.

** UPDATE 27 / JULY / 2016 **

The following link works fine and gets 20 images from Tumblr blog photo posts:

api.tumblr.com/v2/blog/EXAMPLEBLOG.tumblr.com/posts/photos?api_key=XXXXX‌​XXXXXXXX 

The following link does not work and makes the page barf and the photos to disappear:

api.tumblr.com/v2/blog/EXAMPLEBLOG.tumblr.com/posts/photos?limit=50?api_key=XXXXX‌​XXXXXXXX 

The PHP print()/print_r()/var_dump() output I did (to help me program) indicates that the problem is here (so how would I solve this? Do I need to do more back-end user-permission/user-token/OAuth-token/secret-token back-end PHP programming to access this possibility to get photo limit of 50 in Tumblr as per help advised by lharby(in comments) below?):

RAW JSON DATA = Array ( meta => Array ( [status] => 401 [msg] => Unauthorized ) [response] => Array ( ) 

ARRAY OF KEYS = Array ( [0] => meta [1] => response ) 

ARRAY OF VALUES = array(2) { [0]=> array(2) { ["status"]=> int(401) ["msg"]=> string(12) "Unauthorized" } [1]=> array(0) { } } 

TEST PHOTO EXTRACTION
HERE IS THE $Array0 INFO, KEY = 0 Array
HERE IS THE $ArrayResponse INFO, KEY = status401
HERE IS THE $ArrayResponse INFO, KEY = msgUnauthorized