-
-
Save encounter/3de4704e6e9e19121e844b4d7f6bc5e1 to your computer and use it in GitHub Desktop.
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 | |
const watchpitch_base_url = 'https://www.watchpitch.com'; | |
const watchpitch_content = watchpitch_base_url . '/wp-content/uploads'; | |
const watchpitch_s3_base_url = 'https://s3.amazonaws.com/watchpitch'; | |
const username = 'foo'; | |
const apikey = 'bar'; | |
const publish_code = 37; | |
$username_encoded = urlencode($username); | |
$apikey_encoded = urlencode($apikey); | |
$url = "https://$username_encoded:$apikey_encoded@www.watchpitch.com/wp-json/wp/v2/pitch?publish_code=$publish_code&_embed=author"; | |
$response = file_get_contents($url); | |
if ($response == false) { | |
return '<pre>WatchPitch Error: failed to fetch content</pre>'; | |
} | |
$json = json_decode($response, true); | |
?> | |
<div id="watchpitch_content"> | |
<?php foreach ($json as $pitch) { ?> | |
<div class="pitch-block"> | |
<?php $author = $pitch['_embedded']['author'][0]; | |
if ($author) { | |
$pfp_url = $author['avatar_urls']['24']; | |
if ($author['acf']['profile_picture']) { | |
$pfp_url = $author['acf']['profile_picture']['sizes']['thumbnail']; | |
} | |
?> | |
<p class="author-title"> | |
<img width="24" height="24" src="<?= $pfp_url ?>" alt="<?= $author['name'] ?>" | |
style="display: inline; vertical-align: text-top" /> | |
<?= htmlspecialchars($author['name']) ?> | |
</p> | |
<?php } ?> | |
<h6 class="title"><?= $pitch['title']['rendered'] ?></h6> | |
<video poster="<?= watchpitch_content . '/' . $pitch['better_featured_image']['media_details']['file'] ?>" controls style="width: 100%"> | |
<source src="<?= watchpitch_s3_base_url . '/' . $pitch['acf']['s3_video_url'] ?>" type="video/mp4"> | |
</video> | |
<?php if ($pitch['acf']['summary']) { ?> | |
<br /><p class="description"><strong>Description:</strong> <?= nl2br(htmlspecialchars($pitch['acf']['summary'])) ?></p> | |
<?php } ?> | |
</div> | |
<?php } ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment