通过 instagram api 获取评论
Get comments by instagram api
当我尝试向媒体发表评论时,它 returns 我只能访问令牌所有者用户的评论,而不能访问其他用户的评论。
查询:
https://api.instagram.com/v1/media/"+mediaId+"/comments?access_token="+token
所以最终查询看起来像:
https://api.instagram.com/v1/media/1162251688307718037_1824437940/comments?access_token=token
答案:
`{"meta":{"code":200},"data":[{"created_time":"1453069290","text":"comment_text_here","from":{"username":"username","profile_picture":"profile_picture","id":"user_id","full_name":"full_name"},"id":"1164752089812694405"}]}'
获取媒体 ID:
https://api.instagram.com/v1/users/self/media/recent/?access_token="+token+"&count=30
正在获取媒体 ID 列表
JSONObject json = new JSONObject(comments);
JSONArray data = json.getJSONArray("data");
if (data.length()>0) {
for (int i = 0; i < data.length(); i++) {
JSONObject obj = (JSONObject) data.get(i);
list.add(obj.getString("id"));
//System.out.println(obj.getString("id"));
}
}
我的错误在哪里还是 api 沙盒应用程序的 instagram 限制?
是的,在沙盒模式下,它将 return 仅来自沙盒授权用户的媒体,如果您将已评论的用户添加到您的沙盒,则该评论将显示在 API 响应中。
https://www.instagram.com/developer/sandbox/
To help you develop and test your app, the users and media available
in Sandbox mode are real Instagram data (i.e. what is normally visible
in the Instagram app), but with the following conditions:
- Apps in sandbox are restricted to 10 users
- Data is restricted to the 10 users and the 20 most recent media from each of those users
- Reduced API rate limits
当我尝试向媒体发表评论时,它 returns 我只能访问令牌所有者用户的评论,而不能访问其他用户的评论。
查询:
https://api.instagram.com/v1/media/"+mediaId+"/comments?access_token="+token
所以最终查询看起来像:
https://api.instagram.com/v1/media/1162251688307718037_1824437940/comments?access_token=token
答案:
`{"meta":{"code":200},"data":[{"created_time":"1453069290","text":"comment_text_here","from":{"username":"username","profile_picture":"profile_picture","id":"user_id","full_name":"full_name"},"id":"1164752089812694405"}]}'
获取媒体 ID:
https://api.instagram.com/v1/users/self/media/recent/?access_token="+token+"&count=30
正在获取媒体 ID 列表
JSONObject json = new JSONObject(comments);
JSONArray data = json.getJSONArray("data");
if (data.length()>0) {
for (int i = 0; i < data.length(); i++) {
JSONObject obj = (JSONObject) data.get(i);
list.add(obj.getString("id"));
//System.out.println(obj.getString("id"));
}
}
我的错误在哪里还是 api 沙盒应用程序的 instagram 限制?
是的,在沙盒模式下,它将 return 仅来自沙盒授权用户的媒体,如果您将已评论的用户添加到您的沙盒,则该评论将显示在 API 响应中。
https://www.instagram.com/developer/sandbox/
To help you develop and test your app, the users and media available in Sandbox mode are real Instagram data (i.e. what is normally visible in the Instagram app), but with the following conditions:
- Apps in sandbox are restricted to 10 users
- Data is restricted to the 10 users and the 20 most recent media from each of those users
- Reduced API rate limits