Skip to content

Instantly share code, notes, and snippets.

@brandonkramer
Last active May 30, 2021 17:12
Show Gist options
  • Save brandonkramer/9746f3a1f70c0bce6f168e985f4f161e to your computer and use it in GitHub Desktop.
Save brandonkramer/9746f3a1f70c0bce6f168e985f4f161e to your computer and use it in GitHub Desktop.
Instagram oEmbed / embed request with PHP / Curl
<?php
// Access token with App Id
$appId = "";
$accessToken = "";
function fetchData( $url ) {
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 20 );
$result = curl_exec( $ch );
curl_close( $ch );
return $result;
}
$result = fetchData(
"https://graph.facebook.com/v10.0/instagram_oembed?url=https://www.instagram.com/p/fA9uwTtkSN/&access_token={$appId}|{$accessToken}"
);
$result = json_decode( $result );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment