Lately, I have been working with Instagram API to build a social networking website where I used many of its features including showing public images under a specific #hashtag.
The hashtag is a brilliant social media feature, which is already being used in all major social networking websites including Facebook and Twitter. In this post, you will see how we can grab all images from Instagram with a specific hashtag using its API and PHP.
Each API needs registration before you can use its features. Please note, for showing images under a specific hashtag, we don’t need any authentication but for connecting to Instagram API we do need client ID and client secret keys which we will get once we will register an app on the Instagram API platform.
So our first step will be to register an app on the Instagram API page https://instagram.com/developer/ and click on the “Register Your Application” button.
The next page is the Manage Clients page, where we need to add a client to get the required authentication keys, i.e. Client ID and Client Secret. Please click on the “Register New Client” button to see the client registration form.
In this form, we will provide an app name that should represent your website or company name for easily understandable for the end users. I used the “99Points Hashtag” here as an example. Provide a short but clear description to let the user know what is this app for. Add website and redirect URL. Both URLs can be the same as we don’t need them here for showing the images only. Enter the information and click on the “Register” button.
The next screen shows the success message with the Client ID and Client Secret keys which we will use in our last step.
Finally, we have created the app on Instagram, and now its PHP-Action-Time. The below API URL is a direct way to bring all the images having a specific hashtag. It takes the hashtag and client ID which we already have above and then it brings the results in JSON format. Is it not easy?