G
G
Genri_Rus2021-03-27 01:01:34
JavaScript
Genri_Rus, 2021-03-27 01:01:34

What is the right way to get posts (feed) on instagram now?

Here is an example request:

const userID = 2879996464;

jQuery.ajax({
  url: 'https://api.instagram.com/v1/users/' + userID + '/media/recent',
  dataType: 'jsonp',
  type: 'GET',
  data: {access_token: tok, count: kolichestvo}, // передаем параметры, которые мы указывали выше
  success: function(result){
 		console.log(result);
    for( x in result.data ){
      jQuery('.new_list').append('<li><div class="img"><a href="'+result.data[x].link+'" target="_blank"><img alt="" src="'+result.data[x].images.low_resolution.url+'"></a></div><div class="links"><span class="like">'+result.data[x].likes.count+'</span><span class="comment">'+result.data[x].comments.count+'</span></div></li>');
      // result.data[x].images.low_resolution.url - это URL картинки среднего разрешения, 306х306
      // result.data[x].images.thumbnail.url - URL картинки 150х150
      // result.data[x].images.standard_resolution.url - URL картинки 612х612
      // result.data[x].link - URL страницы данного поста в Инстаграм 
      // result.data[x].likes.count - likes count
      // result.data[x].comments.count - comments count
    }
  },
  error: function(result){
    console.log(result);
  }
});

But I'm getting an error:
{"meta": {"code": 400, "error_type": "OAuthAccessTokenException", "error_message": "The access_token provided is invalid."}}

How to get posts through the frontend?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad, 2021-03-27
@Genri_Rus

The error occurs due to problems with the token, you need to dig in the direction of authorization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question