Created
May 30, 2020 16:56
-
-
Save jxxe/890ed1493e1de3eedf452f17b4bc916c to your computer and use it in GitHub Desktop.
MemeCitations Instagram Fix
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 | |
header('Content-Type: application/json'); | |
if(!empty($_POST)) { | |
$post = $_POST; | |
$post = json_decode($post, true); | |
$data = file_get_contents('https://api.instagram.com/oembed/?url=' . $post['url']); | |
$data = json_decode($data, true); | |
$dom = new DomDocument(); | |
@$dom->loadHTML($data['html']); | |
$dates = $dom->getElementsByTagName('time'); | |
foreach($dates as $date) { | |
$date = $date->getAttribute('datetime'); | |
break; | |
} | |
$date = date('j M Y', strtotime($date)); | |
$citation = 'MLA Citation: | |
@' . $data['author_name'] . ' "' . substr($data['title'], 0, 10) . '..." Instagram, ' . $date . ', ' . $post['url'] . ' #MemeCitations'; | |
$response = [ | |
'success' => true, | |
'citation' => $citation | |
]; | |
$response = json_encode($response); | |
print_r($response); | |
} else { | |
echo '{"error":{"type":"miss"}}'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure what you've built the
/api/create
part of your site with. Wappalyzer says that it's PHP, so that's what I'm going to go with.