Skip to content

Commit

Permalink
getMediaLikes, and getMediaComments.
Browse files Browse the repository at this point in the history
Functions to get media comments and likes with paginator.
  • Loading branch information
codexJoin authored May 19, 2020
1 parent 200a442 commit 75472fa
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,42 @@ class Instagram {
data => data.graphql.shortcode_media
)
}
//get comments in media with paginator
//!warning, the pointer can be array or not, if array, you need to convert this!
//to convert pick pointer, just do something like this: let pointer = JSON.parse(pointer); pointer = JSON.stringify(pointer)
async getMediaComments({shortcode, first = 12, after = ''}){
return this.request('/graphql/query/', {
qs: {
query_hash: 'bc3296d1ce80a24b1b6e40b1e72903f5',
variables: JSON.stringify({shortcode: shortcode, first: first, after: after})
}
})
.then(data => data.data.shortcode_media["edge_media_to_parent_comment"])
.then(({count, page_info, edges}) => ({
count, page_info, data: edges.map(edge => edge.node)
}))
}
//get media likes with paginator
async getMediaLikes({shortcode, first = 12, after = ''}){

return this.request('/graphql/query/', {
qs: {
query_hash: 'd5d763b1e2acf209d62d22d184488e57',
variables: JSON.stringify({
shortcode: shortcode,
first: first,
after: after
})
}
})
.then(data => data.data.shortcode_media.edge_liked_by)
.then(({count, page_info, edges }) => ({
count, page_info, data: edges.map(edge => edge.node)
}))


}


async addComment({ mediaId, text, replyToCommentId }) {
return this.request.post(`/web/comments/${mediaId}/add/`, {
Expand Down

0 comments on commit 75472fa

Please sign in to comment.