Last active
May 30, 2021 17:12
-
-
Save brandonkramer/9746f3a1f70c0bce6f168e985f4f161e to your computer and use it in GitHub Desktop.
Instagram oEmbed / embed request with PHP / Curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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