问题
How to extract Instagram Profile picture using instagram API in android ? Or any other Method To extract Insta Profile Picture?
回答1:
Use one of these URL
- https://www.instagram.com/USERNAME/?__a=1
- https://i.instagram.com/api/v1/users/USER_ID/info/
NOTE: To get Instagram user id
, use first URL with Instagram username
回答2:
To get profile photo, use the function bellow:
function getPhoto(a) {
// validation for instagram usernames
var regex = new RegExp(/^(?!.*\.\.)(?!.*\.$)[^\W][\w.]{0,29}$/);
var validation = regex.test(a);
if(validation) {
$.get("https://www.instagram.com/"+a+"/?__a=1")
.done(function(data) {
// getting the url
var photoURL = data["graphql"]["user"]["profile_pic_url_hd"];
// update img element
$("#photoReturn").attr("src",photoURL)
})
.fail(function() {
// code for 404 error
alert('Username was not found!')
})
} else {
alert('The username is invalid!')
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img src="" id="photoReturn">
<br><br>
<input type="text" id="usernameInput">
<button onclick="getPhoto($('#usernameInput').val().trim())">Get profile photo</button>
回答3:
Using the Instagram API users endpoint (https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN
) you will receive a response like this one:
{
"data": {
"id": "1574083",
"username": "snoopdogg",
"full_name": "Snoop Dogg",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg",
"bio": "This is my bio",
"website": "http://snoopdogg.com",
"counts": {
"media": 1320,
"follows": 420,
"followed_by": 3410
}
}
Using this you can get the profile picture.
来源:https://stackoverflow.com/questions/50086945/how-to-get-instagram-profile-picture