0

I've written a bunch of functions in my theme's functions.php so that I can use a shortcode to post Vine videos, e.g [vine id="hx9LlrZxdqV"]. My functions will then grab the raw .mp4 URL and output it as a video on my post page.

The client also wants me to be add Facebook integration so that when the Post is published with the Vine shortcode in, the video is simultaneously sent to Facebook where it's embedded as video so the users can play it on Facebook as well, much like Vinescope do.

As an addition, I will also need to add the Facebook comments to to WP post and possibly also get the number of Likes and Shares for each video/Facebook post.

Here are my functions to output the Vine on Wordpress:

function vine($id) { // gets the raw .mp4 url from the vine id
    $vine = file_get_contents("http://vine.co/v/{$id}");
    preg_match('/property="twitter:player:stream" content="(.*?)"/', $vine, $matches);
    return ($matches[1]) ? $matches[1] : false;
}
function vineDesc($id) {
    $vine = file_get_contents("http://vine.co/v/{$id}");
    preg_match('~<\s*meta\s+property="(twitter:description)"\s+content="([^"]*)~i', $vine, $matches);
    return ($matches[2]) ? $matches[2] : false;
}
function vineAuthor($id) {
    $vine = file_get_contents("http://vine.co/v/{$id}");
    preg_match('~<\s*meta\s+property="(twitter:title)"\s+content="([^"]*)~i', $vine, $matches);
    $authorName = preg_replace('/\'s post on Vine/', '', $matches[2]);
    return ($authorName) ? $authorName : false;
}


function embedVine($atts) {

    extract(shortcode_atts(array(
        "id" => '',
    ), $atts));

    $vine_id = $id;

    $videourl = vine($vine_id); // assigns the raw .mp4 url from vine() function above to variable
    $vineDesc = vineDesc($vine_id);
    $vineAuthor = vineAuthor($vine_id);

    $output = "";

    $output .= "<div class='vine-video'><video class='vine-embed'><source src=". $videourl ." type='video/mp4'></video><div class='video-overlay is-visible'><img src='/wp-content/themes/hot-new-feed/images/vine-logo.png' alt='Vine' class='vine-logo' /><div class='vine-info'><span class='vine-desc'>" . $vineDesc . "</span><a class='vine-author' href='http://vine.co/v/" . $vine_id . "'> by " . $vineAuthor . " &rarr;</a></div></div>" . postShareBtn() . "</div>";

    return $output;

} add_shortcode("vine", "embedVine");

I'm open to using Plugins but if possible I'd like to avoid using them as much as possible.

EDIT: Also, if the embedding the Vine on Facebook can't be done, it would be ok if it would just post a link to the Vine for the user to click on, and then get the comments and possibly likes/shares too to display on the Wordpress page. Thanks!

Thanks for any help :)

  • what's your question exactly? what research have you done, what have you tried, etc.. – Milo Jan 9 '14 at 17:36
  • My question is, how would I write some PHP/JS or use a plugin to send each Vine that is published to Facebook, possibly embedding it so that a user can play it within Facebook instead of going to the Vine site. I've done some research and found some stuff useful but none that really answer my question. I'm not good enough at APIs and stuff to do this myself so I need some help + advice from you guys (experts!) on here :) – Tom Oakley Jan 9 '14 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.