使用 PHP 透過 flickr API 抓取使用者的所有相片(flickr.people.getPhotos)

分享:
標籤: flickr PHP

首先要申請 API

說明使用 PHP 透過 flickr API 抓取使用者所有相片(flickr.people.getPhotos)的方法。

可以傳入的參數有這些:

api_key (必需的)
Your API application key. See here for more details.
user_id (必需的)
The NSID of the user who's photos to return. A value of "me" will return the calling user's photos.
safe_search (可選的)
Safe search setting:
  • 1 for safe.
  • 2 for moderate.
  • 3 for restricted.
(Please note: Un-authed calls can only see Safe content.)
min_upload_date (可選的)
Minimum upload date. Photos with an upload date greater than or equal to this value will be returned. The date should be in the form of a unix timestamp.
max_upload_date (可選的)
Maximum upload date. Photos with an upload date less than or equal to this value will be returned. The date should be in the form of a unix timestamp.
min_taken_date (可選的)
Minimum taken date. Photos with an taken date greater than or equal to this value will be returned. The date should be in the form of a mysql datetime.
max_taken_date (可選的)
Maximum taken date. Photos with an taken date less than or equal to this value will be returned. The date should be in the form of a mysql datetime.
content_type (可選的)
Content Type setting:
  • 1 for photos only.
  • 2 for screenshots only.
  • 3 for 'other' only.
  • 4 for photos and screenshots.
  • 5 for screenshots and 'other'.
  • 6 for photos and 'other'.
  • 7 for photos, screenshots, and 'other' (all).
privacy_filter (可選的)
Return photos only matching a certain privacy level. This only applies when making an authenticated call to view photos you own. Valid values are:
  • 1 public photos
  • 2 private photos visible to friends
  • 3 private photos visible to family
  • 4 private photos visible to friends & family
  • 5 completely private photos
extras (可選的)
A comma-delimited list of extra information to fetch for each returned record. Currently supported fields are: description, license, date_upload, date_taken, owner_name, icon_server, original_format, last_update, geo, tags, machine_tags, o_dims, views, media, path_alias, url_sq, url_t, url_s, url_q, url_m, url_n, url_z, url_c, url_l, url_o
per_page (可選的)
Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.
page (可選的)
The page of results to return. If this argument is omitted, it defaults to 1.

 

回傳的內容大概會長這樣

<photos page="2" pages="89" perpage="10" total="881">
	<photo id="2636" owner="[email protected]" 
		secret="a123456" server="2" title="test_04"
		ispublic="1" isfriend="0" isfamily="0" />
	<photo id="2635" owner="[email protected]"
		secret="b123456" server="2" title="test_03"
		ispublic="0" isfriend="1" isfamily="1" />
	<photo id="2633" owner="[email protected]"
		secret="c123456" server="2" title="test_01"
		ispublic="1" isfriend="0" isfamily="0" />
	<photo id="2610" owner="[email protected]"
		secret="d123456" server="2" title="00_tall"
		ispublic="1" isfriend="0" isfamily="0" />
</photos>

 

API 說明
flickr.people.getPhotos

和我們交流

加入我們的社群,裡面會有一些技術的內容、有趣的技術梗,以及職缺的分享,歡迎和我們一起討論。