The MU forums have moved to WordPress.org

Getting Flash + XML + YouTube to work in header.php? (1 post)

  1. rcwatson
    Member
    Posted 15 years ago #

    I need help to embed a .swf file that uses an XML data source to pull videos from YouTube. The .swf file and xml data source work perfectly when executed on my Desktop. But when I upload and embed it into header.php on the server (using swfobject.js), nothing will load.

    I've been over this with the software vendor and can affirm it's nothing to do with the Flash component. Something in WPMU is blocking the .swf from downloading data from YouTube.

    There is a proxy file that is supposed to make this communication possible. It's in the directory with the .swf and looks like this:


    <?php
    $url = trim($_REQUEST['url']);
    if (strpos($url, 'http://www.youtube.com/watch?v=') === 0)
    {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $info = curl_exec($ch);

    $pos1 = strpos($info, "&video_id=", $pos1);
    $pos2 = strpos($info, "&t=", $pos2);

    $video_id = substr($info, $pos1 + 10, 11);
    $tag_t = substr($info, $pos2 + 3, 32);

    $response = '<video>';
    $response .= '<id>' . $video_id . '</id>';
    $response .= '<t>' . $tag_t . '</t>';
    $response .= '</video>';

    header("Content-type: text/xml");

    echo $response;

    curl_close($ch);
    } else
    {
    die("Wrong URL / Parameters");
    }
    ?>

About this Topic

  • Started 15 years ago by rcwatson