2012-11-01 100 views

回答

5

看看這裏,以便開始: http://instagram.com/developer/

,然後才能按標籤檢索圖片,看看這裏: http://instagram.com/developer/endpoints/tags/

從Instagram的獲取標籤不需要OAuth的,所以您可以通過以下網址進行電話:

GET IMAGES https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token={TOKEN}

SEARCH https://api.instagram.com/v1/tags/search?q={tag-query}&access_token={TOKEN}

TAG INFO https://api.instagram.com/v1/tags/{tag-name}?access_token={TOKEN}

14

首先,Instagram的API端點 「標籤」 需要OAuth認證。

可以使用以下網址

查詢(在這種情況下大雪)的特定主題標籤的結果是速率限制到5000(X-Ratelimit限:5000)每小時

https://api.instagram.com/v1/tags/snowy/media/recent

樣本響應

{ 
    "pagination": { 
    "next_max_tag_id": "1370433362010", 
    "deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead", 
    "next_max_id": "1370433362010", 
    "next_min_id": "1370443976800", 
    "min_tag_id": "1370443976800", 
    "next_url": "https://api.instagram.com/v1/tags/snowy/media/recent?access_token=40480112.1fb234f.4866541998fd4656a2e2e2beaa5c4bb1&max_tag_id=1370433362010" 
    }, 
    "meta": { 
    "code": 200 
    }, 
    "data": [ 
    { 
     "attribution": null, 
     "tags": [ 
     "snowy" 
     ], 
     "type": "image", 
     "location": null, 
     "comments": { 
     "count": 0, 
     "data": [] 
     }, 
     "filter": null, 
     "created_time": "1370418343", 
     "link": "http://instagram.com/p/aK1yrGRi3l/", 
     "likes": { 
     "count": 1, 
     "data": [ 
      { 
      "username": "iri92lol", 
      "profile_picture": "http://images.ak.instagram.com/profiles/profile_404174490_75sq_1370417509.jpg", 
      "id": "404174490", 
      "full_name": "Iri" 
      } 
     ] 
     }, 
     "images": { 
     "low_resolution": { 
      "url": "http://distilleryimage1.s3.amazonaws.com/ecf272a2cdb311e2990322000a9f192c_6.jpg", 
      "width": 306, 
      "height": 306 
     }, 
     "thumbnail": { 
      "url": "http://distilleryimage1.s3.amazonaws.com/ecf272a2cdb311e2990322000a9f192c_5.jpg", 
      "width": 150, 
      "height": 150 
     }, 
     "standard_resolution": { 
      "url": "http://distilleryimage1.s3.amazonaws.com/ecf272a2cdb311e2990322000a9f192c_7.jpg", 
      "width": 612, 
      "height": 612 
     } 
     }, 
     "users_in_photo": [], 
     "caption": { 
     "created_time": "1370418353", 
     "text": "#snowy", 
     "from": { 
      "username": "iri92lol", 
      "profile_picture": "http://images.ak.instagram.com/profiles/profile_404174490_75sq_1370417509.jpg", 
      "id": "404174490", 
      "full_name": "Iri" 
     }, 
     "id": "471425773832908504" 
     }, 
     "user_has_liked": false, 
     "id": "471425689728724453_404174490", 
     "user": { 
     "username": "iri92lol", 
     "website": "", 
     "profile_picture": "http://images.ak.instagram.com/profiles/profile_404174490_75sq_1370417509.jpg", 
     "full_name": "Iri", 
     "bio": "", 
     "id": "404174490" 
     } 
    } 
} 

您可以播放在這裏:

https://apigee.com/console/instagram?req=%7B%22resource%22%3A%22get_tags_media_recent%22%2C%22params%22%3A%7B%22query%22%3A%7B%7D%2C%22template%22%3A%7B%22tag-name%22%3A%22snowy%22%7D%2C%22headers%22%3A%7B%7D%2C%22body%22%3A%7B%22attachmentFormat%22%3A%22mime%22%2C%22attachmentContentDisposition%22%3A%22form-data%22%7D%7D%2C%22verb%22%3A%22get%22%7D

你需要使用「認證」 OAuth的2,將促使他們通過Instagram的到簽到。 發佈您可能必須重新添加「模板」部分中的「標籤名稱」。

所有與分頁相關的數據都可以在響應中的「pagination」參數中找到,並使用它的「next_url」來查詢下一組結果。

+0

如何獲取下一頁網址?我的意思是獲得下一組的反應在PHP或JavaScript? – user1788736

+0

在響應中使用「next_url」以查詢更多結果。您可以在http://instagram.com/developer/endpoints/「分頁」部分閱讀更多內容。 –

10

目前還不可能使用多個標籤來搜索內容,目前只支持單個標籤。

首先,Instagram API端點「標籤」需要OAuth認證。

這不是真的,你只需要一個API密鑰。只需register一個應用程序,並將其添加到您的請求。 實施例:

https://api.instagram.com/v1/users/userIdYouWantToGetMediaFrom/media/recent?client_id=yourAPIKey 

還要注意,用戶名不是用戶ID。您可以查找用戶ID的here.

如果您爲每個標記啓動一個請求並在服務器上比較結果,則搜索多個關鍵字的解決方法就是如果您想要搜索多個關鍵字,當然,這可能會減慢你的網站,取決於你想要比較多少關鍵字。

相關問題