Skip to content

Instantly share code, notes, and snippets.

View inadeemkhan's full-sized avatar
💻
Keep Calm & Clear Cache

Nadeem Khan inadeemkhan

💻
Keep Calm & Clear Cache
View GitHub Profile
@inadeemkhan
inadeemkhan / InstagramFeed
Created May 23, 2023 10:32
PHP Curl code to get the Instagram image.
// PHP code:
function getInstagramFeeds($limit = 1){
$api_url = "https://graph.instagram.com/me/media?fields=id,media_type,media_url,username,timestamp&access_token=IGQ****&count=".$limit;
$connection_c = curl_init(); // initializing
curl_setopt( $connection_c, CURLOPT_URL, $api_url ); // API URL to connect
curl_setopt( $connection_c, CURLOPT_RETURNTRANSFER, 1 ); // Return the result, do not print
curl_setopt( $connection_c, CURLOPT_TIMEOUT, 20 );
$json_return = curl_exec( $connection_c ); // Connect and get json data
curl_close( $connection_c ); // Close connectionßßß
$insta = json_decode( $json_return ); // Decode and return