Blog

Tagged by 'instagram api'

  • This is something I have been meaning to post for quite some time, ever since I first started working on integrating Instagram's API in web applications from 2013. - The ability to resize an image from Instagram without having to deal with registering for an API key and worrying about request limits.

    This approach is ideal if you have no requirement to get further information about an image, such as description, comments, likes etc.

    Believe it or not, Instagram contains quite a neat (somewhat hidden) feature that gives you the ability to output three different sized images directly into a webpage, by constructing the path to an image as so: https://www.instagram.com/p/<image-id>**/media/?size=<size-parameter>**.

    The supported "size parameters" are:

    • t - for thumbnail (150px x 150px)
    • m - for medium (306px x 306px)
    • l - for large (640px x 640px)

    The great thing about using the media parameter is that the requested image size is served up immediately. For example, we could embed an Instagram image directly into our HTML markup as so:

    <p style="text-align: center;">
      <img alt="Mr. Brown - The Office Dog" src="https://www.instagram.com/p/uz_8x2qW6E/media/?size=m">
    </p>
    

    Which will render the following output:

    Mr. Brown - The Office Dog

    In this case, this is a picture of Mr. Brown (the office dog) from my Instagram profile in medium size.

  • Over the last few projects I've been working on, I started to notice that clients are requiring increased integration with social platforms that give them the ability to display key elements from well known social platforms, such as YouTube, Twitter and Instagram. Hence the reason why in the past I created a YouTube Form Control that would easily retrieve all information information about a video along with their screen caps by simply entering the YouTube URL.

    Recently, I've been working on two more form controls involving Twitter and Instagram to further enhance social platform integration within Kentico from a user standpoint, which (I think) is quite neat!

    Twitter

    Using a combination of OAuth and Twitter'sGET statuses/show/:id API endpoint, I was able to store within Kentico all JSON data relating to a tweet by just entering the ID. One major advantage to storing JSON data is that we can display the tweet as many times as we want throughout the site without worrying about breaching API limits.

    In addition, individual elements of a tweet, such as the embedded image, hash tags and author information can be used when required.

    Tweet Custom Form Control

    As you can see (above), I am using Twitter's Embedded Tweet plugin to display the tweet in a nice graphical representation so that the site administrator is able to view contents of the tweet prior to publishing live.

    Instagram

    Like the Twitter control above, details of an Instagram image is retrieved in a similar fashion, whereby I'm storing all the details in JSON format.  In this case, I'm using a combination of two Instagram API endpoint's:

    • /oembed - to get the core information of an image by passing in the full URL of where the image resides. This will return important piece of information: the true ID of the image.
    • /media/media-id - to get all information about the media or video object. This information will be stored in Kentico.

    Unlike Twitter, Instagram's API is a breeze to implement. There are no API limits (at time of writing) and all you need to access the endpoints is to generate a one time only access token.

    Instagram Custom Form Control

    By copying and pasting the link of an Instagram image will return all object information and display the image/video within CMS Desk.

    I will at some point write a blog post on how I created these two controls once I have refactored all the code into one single control. At the moment, some key functionality is segregated into separate class libraries.