Welcome Guest, Not a member yet? Register   Sign In
Video Embed Code Security?
#1

[eluser]Gewa[/eluser]
I am making a web site, where I want users to add Videos to their profile by just dropping ebed code of any video hosting provider, and submit it.
The data are then stored in mysql...
I wonder if it's safe?
How should be data prepped?
#2

[eluser]JHackamack[/eluser]
One suggestion to have is have them copy in the URL of the video and then parse that.

Example
1.) I go to youtube
2.) Copy the URL of a video I like
3.) I paste it in
4.) You have preset video sites you know of that fill in the rest of the embed code

Some sites might have javascript to embed the movies and unless your users are very tech savey requiring them to copy the embed code if it isn't immediately provided by the hosting provider it might be better to build around a few of the popular ones and then look at where people get their videos to see if you need to do more.
#3

[eluser]Peng Kong[/eluser]
Here's what i did... currently only done for youtube and vimeo

Code:
function find($str)
    {
        if (strpos($str, 'youtube.com')) {
            preg_match('!youtube\.com/(.*?)v[=/]([\w\-]+)!i', $str, $matches);
            $video['provider'] = 'youtube';
            $video['key'] = $matches[2];
            $video['file'] = 'http://www.youtube.com/v/'.$matches[2];
               $sxml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/'.$matches[2]);
            // print_r($sxml) //extract other information from here
            $video['title'] = (string)$sxml->title;
            $video['description'] = (string)$sxml->content;
            $video['thumbnail'][0] = 'http://img.youtube.com/vi/'.$matches[2].'/0.jpg';
            $video['thumbnail'][1] = 'http://img.youtube.com/vi/'.$matches[2].'/1.jpg';
            $video['thumbnail'][2] = 'http://img.youtube.com/vi/'.$matches[2].'/2.jpg';
            $video['thumbnail'][3] = 'http://img.youtube.com/vi/'.$matches[2].'/3.jpg';
            return $video;
        }
        elseif (strpos($str, 'vimeo.com')) {
            preg_match('!vimeo\.com/(moogaloop.swf?clip_id=)*([\d]+)!i', $str, $matches);
            $video['provider'] = 'vimeo';
            $video['key'] = $matches[2];
            $sxml = simplexml_load_file('http://vimeo.com/api/v2/video/'.$matches[2].'.xml');
            //print_r($sxml); //extract other information from here
            $video['title'] = (string)$sxml->video->title;
            $video['description'] = (string)$sxml->video->description;
            $video['thumbnail'][0] = (string)$sxml->video->thumbnail_large;
            $video['thumbnail'][1] = (string)$sxml->video->thumbnail_medium;
            $video['thumbnail'][2] = (string)$sxml->video->thumbnail_small;
            return $video;
        }
        return false;
    }

both the video URL and embed code will work.

It will return you the video "key" which allows you to get everything else...

e.g. if the youtube video key is "tHbh_n_P5xk"
to see the video - http://www.youtube.com/v/tHbh_n_P5xk
to get the thumbnail - http://img.youtube.com/vi/tHbh_n_P5xk/2.jpg
#4

[eluser]Gewa[/eluser]
Hi Guys.
I found this awesome service..

www.oohembed.com

You give the url , you get back JSONified data about video. most of the providers I need supported.

For example you make get request to

http://oohembed.com/oohembed/?url=http:/...ander_tech

And get video data ...

Any way I need to have my own code..Sad
And I didn't get how the URL after ?= is encoded.... php function urlencode() doesn't work...
#5

[eluser]123wesweat[/eluser]
at peng kong,

tx for sharing i am playing with it now.

do you have a function which gets the vids/thumbs from a specific user
#6

[eluser]Peng Kong[/eluser]
Hi 123wesweat,

What you're asking is quite different from this thread is about. The two functions i posted above are to get individual video information based on a given (youtube/vimeo) video URL or video embed code.

i don't have a function to "get videos of a specific user" but you should be able to easily create one yourself.

Let me give you a head start:

For Vimeo:

If you want to get videos of a specific users look at http://vimeo.com/api/docs/simple-api#user
the format is http://vimeo.com/api/v2/username/request.output
the example is http://vimeo.com/api/v2/elpizo/videos.xml
Retrieve the data in the format you want to work with: JSON, XML or PHP

For YouTube

see http://code.google.com/apis/youtube/2.0/...ng_Uploads
example http://gdata.youtube.com/feeds/api/users/zetallite/uploads
Google returns you data as an ATOM feed. Use the Zend GData Library if you don't want to work directly with the atom feed. http://framework.zend.com/download/gdata/ or check out simplepie
#7

[eluser]123wesweat[/eluser]
hi Peng Kong tx for your reply

I am testing/trying with simplepie, i just need the last 5 thumbs + player in my website should be doable, right?

I am able to retrieve a list of links per user.
#8

[eluser]Peng Kong[/eluser]
yep definitely doable. it's just a matter of reading the results returned by each API, that's the only 'tricky' part if there's anyway.

i'm not sure if we're hjiacking this thread. If you want to discuss anything that isn't what this thread is about do create a new thread and we can continue from there.




Theme © iAndrew 2016 - Forum software by © MyBB