I have some videos uploaded on viddler, now need the raw file/video link in mp4 format so i send it as a json rest API request to the android app,at the moment I can get the html links to it but I need this too, is such a thing possible? My website is in word press, and I am using the Viddler WordPress plugin.
After my wrong comment, A quick look at there API documentation. I think you would use viddler.videos.getDetails and after json_decode()'ing it access the value as:
$resp->video->url
or
$resp->video->html5_video_source
Which would be a url like:
http://www.viddler.com/file/VIDEO_KEY/html5
Or whichever one returns something like the following is what your after: (Note: I dont use there API, and it doesn't show the format of the url in the documentation):
http://www.viddler.com/file/d/48eaa1ff.mp4
Also there is a Viddler PHP Wrapper that might make it easyier for you then writing your own wrapper for there API.
Edit see comment,
By you supplying the link to the video, I can deduce my answer to:
Its not a direct link to the file; a9fcd88d is the id for that video. Your need to use that id as the video_id parameter, in the following API request (viddler.videos.getDetails):
GET /api/v2/viddler.videos.getDetails.php?sessionid=SESSIONID&key=YOUR_API_KEY&video_id=a9fcd88d
Its all in the docs link above, see click this link (notice the id) http://www.viddler.com/file/a9fcd88d/html5 your see its webm type or HTML5 fallback video.
But, your after .mp4 version which is not offered as std, so your need to use that id(a9fcd88d) to get the mp4 version from that API result set, which I don't know the result of $resp->video->url response, because its not in the docs, else it would be easy to just parse the id and download in mp4 format.
Also they make a futile attempt to make it secure by the player being built through an iframe with javascript, obfuscation and a XSRF token but with some simple console and breakpoints its trivial to get to the actual path of the video and download it (fail...):
http://mynivo-vfs.cdn-ec.viddler.com/mynivo_1s219veo8r3sp77i3oaz90bwhjar3c.mp4?fd9f2a1c14aadf1069f046c16bf41e2b3776a6b320734cdc73d93c30ad8d0e26c7fa5d6ea6105bad4ec694d7af6126c6df817ecdfe80910ce08b938b90e4efc7de19e2b64be6fbfaa9ab32e29b3f
How long that key parameter stays active I dont know... (edit) actually couple of minutes later its now the following, so it is time based.
http://mynivo-vfs.cdn-ec.viddler.com/mynivo_1s219veo8r3sp77i3oaz90bwhjar3c.mp4?fd9f2a1c14aadf1069f046c16bf41e2b3776a6b320734cdc73d93c30ad8d0d2bf4206bd54f270ce83a6237e126803d96b8d90f53e539676c7518df3e497affdd3018bb2c364035984d1b934be221
Hope it helps, basically use the API to get the unsecured mp4 version url, which I presume will be in $resp->video->url
Edit 2
But unless you want to download the video, you might as well use the provided embed code link in an iframe, for example.
<?php
$video_id = 'a9fcd88d';
echo '<iframe width="100%"
height="100%"
src="http://www.viddler.com/embed/'.$video_id.'"></iframe>';
?>
Related
Situation
In my application I have a WebView which loads its data inside an IFrame from an url.
Code Snippet:
String url = www.myexampleurl.com/video1.html;
String data = "<IFRAME SRC=" + url + " FRAMEBORDER=0 ... />";
WebView.loadData(data, MIME_TYPE, ENCODING);
The website itself, loads his video into a flash player and I simply display this in the WebView. This works perfectly, with one nasty sidenote... Android has stopped supporting flash which means in the future my application will not work anymore by default. -Not acceptable!-
What I tried already
Solution to replace the flashplayer
I fetched the url of the video that is given to the flashplayer and I load it directly inside a VideoView or WebView with HTML5. These work solutions work! Perfect! But again a nasty sidenote.
The url (ex. www.myexampleurl.com/video1/video.mp4) is being generically created by the website (I think for each session). This means I don't have a consistent path to the video to load in my View. The advantage of my first approach with the flashplayer inside the Webview was that the flashplayer does all the work.
Solution to get the correct video-url
No serious problem yet, because I can tackle this problem too. I can do some PHP/DOM-scripting which would scrape the website for the video-url and give it back to my application. This way I always have the generic url and my video can be loaded inside my View. Again that works! And again.. there is a sidenote..
I can not go directly to my website that has the flashplayer. The flow can be as followed:
Enter www.myexampleurl.com/video1.html
Get the message: Wait 5 seconds
Click continue
Video is starting to play inside the flashplayer.
The problem is that I get my video url only after step 3.
Question
Is there a way to solve my getting-the-generic-url problem? Or a better approach to play the video?
-- Is it bad, very bad or extremely bad practice to continue to support flash in Android? I can also just provide the flashplayer .apk and let users install it..
Thanks, hope someone can help me :)!
Don't do drugs. Don't do flash.
Get the file up on a server you have control of so you can give a proper path. If that is not an option, you'll have an app that can brake any moment the owner of the website decides to change something with the path.
Is parsing www.myexampleurl.com/video1.html the only way to fecth the url you want?
Maybe you can do the PHP/dom stuff in the client instead of in your server: use an invisible WebView to load www.myexampleurl.com/video1.html and try to get the url from it.
WebViewClient::onLoadResource(WebView view, String url) may be helpful (I am not sure). This task must be achievable by hacking WebView, the problem is how complicated it will be.
So what I am trying to do is this:
On my server users can put there YouTube channel name. My php file will then parse the channel and output HTML code with results. What I am looking to do is for the users to be able to put a code on there website that till call on my website lets say youtubevideos.com/videos.php?channel=channelname my code will take that name and output the videos back to there site. much like Google ads I guess.
Any idea how that is done, other than an iframe, I figured that will be my last resort.
I think what I'm looking for if for them to put a JavaScript on there site that will render as the HTML code I'm pushing from my php file.
Thank you!
The receiver code which is on the server you target need to set a header like that :
"Access-Control-Allow-Origin:*"
So, if you provide a service which need to exchange with your server & your code, is it possible. If you can't edit the targeted code & the header is not setted, it'll be impossible
There would be two parts of this solution.
In the videos.php file on your server, you would implement the logic to scrape the data from the original site and format it in the way you want to show on the final website.
For the end user, you would give a code similar to this that they would have to paste in their php pages to display the content from your site.
$your_website_url="http://youtubevideos.com/videos.php?channel=channelname";
//Don't forget the http:// at the start.
echo file_get_contents($your_website_url);
If file_get_contents() gives a security error, you can use curl.
I hope that helps.
I run ads on my site which are usually YouTube videos. I would like to find out if a user clicked these videos. I'm basically trying to use this data in a statistics plugin that I'm creating.
I've tried searching many different keywords but I can't really find anything.
I would appreciate it if I could be pointed in the right direction. Any ideas, hints or links are welcomed.
As you mention YouTube I doubt you have control over the URL.
But, if you can control the URL embedded in the video, then I would suggest building a simple redirect script on your server. Make sure the URL contains either the redirect URL or a code representing the URL which would be held in your Data Base. Add a logging function to the redirect script and hey presto.
If you have no control over the URL, then off the top of my head maybe you could implement some client side JS to add an overlay to the video which becomes the click-able element and implement the URL redirect script above. Some methods to get the URL from the video: https://www.google.com/search?q=jquery+youtube+URL
I am using php to develop a twitter search api which is able to search twitter, and save posted images from tweets.
It all works fine etc, but for facebook, instead of the image being loaded with the webpage, its loaded after in a response. Using firebug, going to the Net tag, I can see the html source code I need under the response tab for a getphoto(). I am looking to grab an img src from this html text, but
Facebook seems to load the basic stucture, then reload the page with the image on it.
My question is: How can I get this 'response body'?
I have used get_headers() before, but I dont think it will work in this situation, and I have trawlled the net looking for an answer to this, but none have appeared.
Any help would be much appreciated, thx in adv.
Dont think my code will help explaining, but willing to put some up
EDIT:
example facebook url: /https://www.facebook.com/photo.php?pid=1258064&l=acb54aab14&id=110298935669685
that would take you to the page containing the image
This is the image tag:
img class="fbPhotoImage img" id="fbPhotoImage" src="https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash3/522357_398602740172635_110298935669685_1258064_1425533517_n.jpg" alt=""
But this does not show up until the response comes through.
I have a get_header funciton in to expand shortened URL's, due to twitters love for them, and this can get and image from other 3rd party photo sites with multiple shortens/redirects.
Have not used cURL before, is it the best/only way?
Thanks again
instead of the image being loaded with the webpage, its loaded after in a response
I don't know what this means.
I can only guess that the URL you are trying to fetch the html from, which your code is expected to parse to extract an image URL, is actually issuing a redirect.
Use curl for your transfers and tell it to follow redirects - NB this will only work with header redirects - not meta equiv redirects, meta refresh redirects nor javascript location redirects.
(maybe Faceboo0k don't want you to leech their content?)
I'm currently displaying pics in my app from twitter's default image service since they get included in the json response but I'd like to try to get images from yfrog, twitpic, lockerz or similar providers.
I'm using the rest api so I was thinking about adding filter:links to the search query, extract the url from the tweet and check if the link is an image but I'm not sure exactly how to get the url since I assume it'll require some regular expressions plus most of the tweets url are shortened versions that redirect to the actual photo somewhere so I believe this could be a problem. It'd be nice if I could verify that the url contains any of the image providers mentioned above too (kind of like a first filter before checking if the url is an image)
Could someone point me in the right direction? Thanks in advance!
For detecting the links, just google for a regex to match a url. Like this here:
http://snipplr.com/view/2371/ or http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers
and cycle through the matches array:
http://php.net/manual/en/function.preg-match.php
This one should solve the short links problem (assuming you have curl installed): follow redirects with curl in php
Use this here to check if the link is an image:
http://php.net/manual/en/function.get-headers.php (parse "Content-Type" for "image")
I hope this helps.