Instagram Hashtag API PHP and JavaScript Integration with RapidAPI

Do you know how to integrate Instagram Hashtag API with your website? In this tutorial, I will show you how to integrate Instagram Hashtag API from RapidAPI with your website using PHP and Javascript.

First You have to go to RapidAPI and subscribe to Instagram Hashtag API 

After subscription, you can see the Test Endpoint option. so you will get the response on the console. you can get lots of different methods of integration codes over there. but here we are using PHP and Javascript.

How to Integrate Instagram Hashtag with PHP

I will share the code here. You can copy and paste to your website.

<?php
$keyword ="nature";
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://instagram-hashtags.p.rapidapi.com/?keyword=".$keyword,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "X-RapidAPI-Host: instagram-hashtags.p.rapidapi.com",
        "X-RapidAPI-Key: xxxxxxxxxx- REPLACE YOUR API KEY HERE-xxxxxxxxx"
    ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}

Here in $reponse variable has the json reponse. You can use the response to do whatever you want.



 

How to Integrate Instagram Hashtag with Javascript (jquery)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
const settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://instagram-hashtags.p.rapidapi.com/?keyword=nature",
    "method": "GET",
    "headers": {
        "X-RapidAPI-Key": "******EnterYourAPIkeyHere*****",
        "X-RapidAPI-Host": "instagram-hashtags.p.rapidapi.com"
    }
};

$.ajax(settings).done(function (response) {
    console.log(response);
});
</script>

You have to replace the API key with your API key to make it work.

Hope you like this. will see you at another one.

 

Post Your Questions on our forum

Post a question on Forum

Ajith Jojo Joseph

Self taught, dedicated young entrepreneur with many licensed products under his sleeve. Passionate about technology, business and excellence in general.

Share with your friends:

Comments are closed.

Export html table to excel, pdf, csv format using Datatable

Do you know how to export html table to excel, pdf, CSV, or excel format using Datatable? If you don’t […]

August 4, 2022

Instagram Hashtag API PHP and JavaScript Integration with RapidAPI

Do you know how to integrate Instagram Hashtag API with your website? In this tutorial, I will show you how […]

August 2, 2022

How to host React Application into Cpanel – Routes not working Htaccess fix

Do you know how to host react applications into Cpanel? After building your react application. you will get an index.html […]

July 28, 2022

How to get user Public IP Address using Javascript

Do you know how to get the user IP address using javascript? I will show you how. Today we are […]

July 27, 2022

Digital Marketing Toolkit

Get Free Access to Digital Marketing Toolkit. You can use all our tools without any limits

Get Free Access Now