Coder Social home page Coder Social logo

mantasmikal / gatsby-source-instagram-all Goto Github PK

View Code? Open in Web Editor NEW
55.0 1.0 20.0 1.96 MB

โš›๏ธ๐Ÿ“ธ Gatsby source plugin that fetches all your instagram media

License: MIT License

JavaScript 100.00%
gatsby-source-instagram instagram-api gatsby source plugin instagram gatsby4

gatsby-source-instagram-all's Introduction

โš›๏ธ๐Ÿ“ธ Gatsby source plugin to fetch ALL your instagram media from Instagram API + Gatsby Image support.

Demo

Install

  1. yarn add gatsby-source-instagram-all
  2. Add this configuration to your gatsby-config.js:
{
     resolve: `gatsby-source-instagram-all`,
     options: {
       access_token: "YOUR_ACCESS_TOKEN",
     }
}

๐Ÿ‘“ Watch this video if you're having trouble generating your access token.

How to use

Query data like this:

query myQuery {
  allInstagramContent {
    edges {
      node {
        caption
        media_url
        localFile {
          childImageSharp {
            gatsbyImageData(layout: CONSTRAINED, placeholder: BLURRED)
          }
        }
        album {
          localFile {
            childImageSharp {
              gatsbyImageData(layout: CONSTRAINED, placeholder: BLURRED)
            }
          }
        }
      }
    }
  }
}

Graphql fields

Field Name Description
caption The Media's caption text
localFile The local image.
id The Media's ID.
media_type The Media's type. Can be IMAGE, VIDEO, or CAROUSEL_ALBUM.
media_url The Media's URL.
permalink The Media's permanent URL. Will be omitted if the Media contains copyrighted material, or has been flagged for a copyright violation.
thumbnail_url The Media's thumbnail image URL. Only available on VIDEO Media.
timestamp The Media's publish date in ISO 8601 format.
username The Media owner's username.
album The CAROUSEL_ALBUM media. Has the same fields as the root media node

Plugin Options

Option Type Description
access_token string Your access token
limit number (optional) Limit number of posts. Default is to fetch all posts
pageLimit number (optional) Limit number of posts fetched per request. Default is 30

Contribute

  1. Fork it
  2. Create your feature branch git checkout -b feature/fooBar
  3. Commit your changes git commit -am 'Add some fooBar'
  4. Push to the branch git push origin feature/fooBar
  5. Create a new Pull Request

gatsby-source-instagram-all's People

Contributors

chadfawcett avatar jchawkins725 avatar jrapala avatar kmelve avatar kyleamathews avatar maco222 avatar mantasmikal avatar ruffcode avatar tsamantanis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gatsby-source-instagram-all's Issues

How to show a carousel?

Hi,

I understand how to show a single picture but canยดt figure out how to get all images when the type is "CAROUSEL_ALBUM".

I am using the following query currently:

  allInstagramContent {
    edges {
      node {
        timestamp
        caption
        media_type
        localImage {
          childImageSharp {
            fluid(maxWidth: 1000, quality: 100) {
              ...GatsbyImageSharpFluid
            }
          }
        }
      }
    }
  }
}

Then I feed the fluid property to the Image tag like this:
<Image fluid={item.node.localImage.childImageSharp.fluid} />

In the case the "media_type" is equal to "CAROUSEL_ALBUM" this will just show the first picture. How can I fetch all images when a post contain more than one?

INSTAGRAM API ERROR: undefined

Just followed the instructions, but somehow it's not accessing Instagram. When I run develop I get this error

INSTAGRAM API ERROR:  undefined
warning The gatsby-source-instagram-all plugin has generated no Gatsby nodes. Do you need it?

And obviously there're no Instagram query nodes to explore

My gatsby-config

module.exports = {
  siteMetadata: {
    title: `--`,
    description: `--.`,
    author: `--`,
  },
  plugins: [
    `gatsby-plugin-styled-components`,
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `markdown`,
        path: `${__dirname}/markdown`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `images`,
        path: `${__dirname}/src/images`,
      },
    },
    {
      resolve: `gatsby-source-instagram-all`,
      options: {
        access_token: 'got from the link you provide',
      },
    },
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `gatsby-starter-default`,
        short_name: `starter`,
        start_url: `/`,
        background_color: `#663399`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
      },
    },
  ],
}

Cannot read property 'next' of undefined

When I installed this plugin following your recommendation I am getting following error:

 ERROR #11321  PLUGIN

"gatsby-source-instagram-all" threw an error while running the sourceNodes lifecycle:

Cannot read property 'next' of undefined



  TypeError: Cannot read property 'next' of undefined
  
  - sourceNodes.js:63 
    [lor-site]/[gatsby-source-instagram-all]/dist/sourceNodes.js:63:40
  
  - Generator.next
  
  - sourceNodes.js:16 asyncGeneratorStep
    [lor-site]/[gatsby-source-instagram-all]/dist/sourceNodes.js:16:103
  
  - sourceNodes.js:18 _next
    [lor-site]/[gatsby-source-instagram-all]/dist/sourceNodes.js:18:194
  
  - task_queues:93 processTicksAndRejections
    node:internal/process/task_queues:93:5
  

warn The gatsby-source-instagram-all plugin has generated no Gatsby nodes. Do you need it?

What could be the issue? I am using Gatsby 3.4.2

Gatsby develop only works first time

Similar issue to what's going on here: gatsbyjs/gatsby#11109

When I run Gatsby develop I get this error:

Error: Invariant Violation: Encountered an error trying to infer a GraphQL typ  e for: "localImage___NODE". There is no corresponding node with the id field m  atching: "ec07e826-36d4-5377-bec9-d9cefe92acb5"

  - invariant.js:40 invariant
    [samchang]/[invariant]/invariant.js:40:15

  - infer-graphql-type.js:234 validateLinkedNode
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:234:5

  - infer-graphql-type.js:293 inferFromFieldName
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:293:3

  - infer-graphql-type.js:359 _.each
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:359:23

  - lodash.js:4911
    [samchang]/[lodash]/lodash.js:4911:15

  - lodash.js:2996 baseForOwn
    [samchang]/[lodash]/lodash.js:2996:24

  - lodash.js:4880
    [samchang]/[lodash]/lodash.js:4880:18

  - lodash.js:9344 Function.forEach
    [samchang]/[lodash]/lodash.js:9344:14

  - infer-graphql-type.js:338 _inferObjectStructureFromNodes
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:338:5

  - infer-graphql-type.js:409 inferObjectStructureFromNodes
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:409:10

  - build-node-types.js:138 inferFields
    [samchang]/[gatsby]/dist/schema/build-node-types.js:138:26

  - build-node-types.js:187 fields
    [samchang]/[gatsby]/dist/schema/build-node-types.js:187:19

  - Array.forEach

  - Array.forEach


error UNHANDLED REJECTION


  Error: Invariant Violation: Encountered an error trying to infer a GraphQL typ  e for: "localImage___NODE". There is no corresponding node with the id field m  atching: "ec07e826-36d4-5377-bec9-d9cefe92acb5"

  - invariant.js:40 invariant
    [samchang]/[invariant]/invariant.js:40:15

  - infer-graphql-type.js:234 validateLinkedNode
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:234:5

  - infer-graphql-type.js:293 inferFromFieldName
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:293:3

  - infer-graphql-type.js:359 _.each
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:359:23

  - lodash.js:4911
    [samchang]/[lodash]/lodash.js:4911:15

  - lodash.js:2996 baseForOwn
    [samchang]/[lodash]/lodash.js:2996:24

  - lodash.js:4880
    [samchang]/[lodash]/lodash.js:4880:18

  - lodash.js:9344 Function.forEach
    [samchang]/[lodash]/lodash.js:9344:14

  - infer-graphql-type.js:338 _inferObjectStructureFromNodes
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:338:5

  - infer-graphql-type.js:409 inferObjectStructureFromNodes
    [samchang]/[gatsby]/dist/schema/infer-graphql-type.js:409:10

  - build-node-types.js:138 inferFields
    [samchang]/[gatsby]/dist/schema/build-node-types.js:138:26

  - build-node-types.js:187 fields
    [samchang]/[gatsby]/dist/schema/build-node-types.js:187:19

  - Array.forEach

  - Array.forEach

But when I delete the cache folder and run Gatsby develop again or completely stopped running Gatsby-source-Instagram-all things seem to work.

localImage null when running gatsby build

Wondering if anyone is seeing an issue where localImage is null when running gatsby build. It works fine when running gatsby develop, but is null when deploying builds. Thanks!

Creating a link to the post on Instagram

Does the Instagram API expose the ID used in the post URL on instagram.com? Ex: post URLs on Instagram have the format of:

https://www.instagram.com/p/CHXs5gVLpVz

How do we access, or create the ID used in the post URL?

Instagram Stories

Hello.
Thanks for the wonderful job.

Please tell me if there is a way to get stories?

How to limit Gatsby to download all content?

First I want to say: Thanks! Thanks for maintaining this plugin, and it works like expected:) One thing though: I want to limit the plugin to only download/query the last 30 posts/images. Now Gatsby is downloading all the content images and for me this is way too much. I saw something about an min_id, max_id, but I am not sure which id exactly is needed? What should the input be if I want to return 30 posts.

Getting Cannot query field "childImageSharp" on type "File"

Used the query as in the example, both here and on Gatsby website:

import { graphql } from 'gatsby';

const query = graphql`
    query myQuery {
        allInstagramContent {
        edges {
            node {
            caption
            media_url
            localImage {
                childImageSharp {
                fluid(maxHeight: 500, maxWidth: 500, quality: 90) {
                    ...GatsbyImageSharpFluid_withWebp
                }
                }
            }
            }
        }
        }
    }
`

Received this error:

error    Cannot query field "childImageSharp" on type "File"  graphql/template-strings

Instagram API response has stopped working

Making the request via the browser works:
https://api.instagram.com/v1/users/self/media/recent/?access_token=______&count=30

However, when requesting via curl/node-fetch/postman the response is simply:

Oops, an error occurred.

I'm not even getting a JSON response. Is anyone else seeing the same behaviour?

Plugin randomly stopped working

Hi, I've got a problem with this plugin: It randomly stopped working, without any changes to my code.

I get the following error: 71:5 error Cannot query field "allInstagramContent" on type "Query" graphql/template-strings

In the GraphiQL editor, the allInstagramContent query isn't available either anymore.

Any ideas what might be going wrong?

error "gatsby-source-instagram-all" threw an error while running the sourceNodes lifecycle

Hi,

I am getting the same error your last deploy preview build got on netlify (also deploying via netlify myself):

error "gatsby-source-instagram-all" threw an error while running the sourceNodes lifecycle: invalid json response body at https://graph.instagram.com/me/media?fields=id,media_url,media_type,permalink,timestamp,caption,username,thumbnail_url,children%7Bid,media_url,media_type,thumbnail_url,timestamp%7D&limit=30 reason: Unexpected token S in JSON at position 0

I have no issues with getting the instagram images showing up in my local dev environment. I added my access token to my .env.production file as well as inside the site settings / build & deploy / environment section.

Any idea how to resolve this? Working so smoothly in local!

Error with graphQL : unknown query with 'allInstagramContent'

Hi.

I've tried your instagram-source and instagram-source-all

both of them, but I met all of failure with them.

although I've installed the dependencies, but graphql doesn't show up the allInstagramContent node or instagram node none of them.

So please let me know what can I do to go further from this.

Thank you for your service!

Node Error: 15847

Hello,

Thank you for your plugin. It's so easy to use.

(node:15847) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

I am running Node v12.13.1 and am getting the above error. Everything works, but I thought I should make an issue so you aware.

Thanks again.

Please update to newest versions of gatsby ecosystem

First, thanks for your great plugin.

I get this error:

 ERROR #85907  GRAPHQL

There was an error in your GraphQL query:

- Unknown field 'localImage' on type 'InstagramContent!'.

File: src/pages/insta.js

My Gatsby project is otherwise updated to latest versions of gatsby packages.
I have reproduced this error by cloning example MantasMikal/gatsby-instagram repository. It worked well but when I updated it to latest versions it started to print the same error.

Video post return null

Hi there, I really like thisp lugin which works great with gatsby v3 and the new Gatsby Image Plugin. I do only have an issue know with video post coming from the feed, localimage return null. Would it be possible in this case to replace the image with the thumbnail generated by instagram for the video ?

Thank you for your time !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.