I'm using SimplePie to parse our church RSS Feed which contains weekly sermons, both audio and video. I'm able to get the title and mp3 link, but having a difficult time getting the youtube link. Below is a sample of what is in the XML feed containing the youtube video.
It's using [CDATA]
I'm using $item->get_content(), but that doesn't seem to contain any of the tag data below. The url for the feed is http://lakeforest.org/feed. When I bring this url up in the browser I can see the embedded youtube video.
Any help would be greatly appreciated.
NOTE: - i commented the html below for display only
<!--
<description><![CDATA[Huntersville Campus Mike Moses, Lead Pastor Series Discussion Questions: SHAPE, Part 2 Spiritual Gifts Inventory VIDEO AUDIO]]></description>
<content:encoded><![CDATA[<h3>Huntersville Campus</h3>
<p>Mike Moses, Lead Pastor<br />
Series Discussion Questions: SHAPE, Part 2<br />
Spiritual Gifts Inventory</p>
<h4>VIDEO</h4>
<p><iframe width="420" height="315" src="http://www.youtube.com/embed/4Uv8U8c6isg" frameborder="0" allowfullscreen></iframe></p>
<h4>AUDIO</h4>
<img src="http://feeds.feedburner.com/~r/LakeForest/~4/qMoLVpI1tGI" height="1" width="1"/>]]> -->
SimplePie strips out embed, object, iframe etc tags by default as they can be dangerous.
You should ignore them if you want the video back, but be careful with the source url as it could be a security issue.
$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
// Remove these tags from the list
$strip_htmltags = $feed->strip_htmltags;
array_splice($strip_htmltags, array_search('object', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('param', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('embed', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('iframe', $strip_htmltags), 1);
$feed->strip_htmltags($strip_htmltags);
Source
I just noticed your feed URL, that wasn't what I was expecting, I was expecting something like this:
http://gdata.youtube.com/feeds/base/videos?q=painting+miniatures+tutorial&orderby=published&client=ytapi-youtube-search&v=2
That is a search result feed from YouTube which I pass to SimplePie here. Also the rest of your PHP code where you declare $item would be useful. I answered a similar question tonight and basically over the years YouTube has changed their API and feeds, you might have to update to a newer version of their API/feed even if you can find old examples of it working.
SimplePie can handle some if not all YouTube feeds, but there is no guarantee Google (YouTube) will give you a thumbnail and all the metadata they have on YouTube.com. APIs usually make a subset of the data contained in their database available via APIs, they want people to come to their website so they can show them ads and track them better.
Not the answer you want perhaps but without more information, that is the best I can do.
If you want to dig into the feed and get the video URL and then create a player for it, that is non-trivial. You have to use something like simple_html_dom then you need to create a properly formatted iframe or javascript call to create the in browser player. SimplePie doesn't have a get_contents()->video
Related
I was wondering what kind of method I could use to directly embed videos or pictures contained in twitter tweets directly ... For example .. below is a tweet from OBAMA
President Obama: "Right now, we have a real chance to reduce gun violence in America." http://t.co/tmCoUsPyyB #TimeToAct
The link that starts with htttp:// could be a picture .. How can I actually program it so that tweets are directly displayed with the images from the urls ? I know PHP and I used the twitter API before , but I dont know how I could easily achieve that . Any help would be appreciated
The first step would to to pull the URLs of of the block of text, there is another question that points you how to solve this: Extract URLs from text in PHP
You can then use Embedly or a service like it to pull the metadata associated with that url. Here is an example of the meta data that Embedly will return: http://embed.ly/docs/explore/oembed?url=http%3A%2F%2Ft.co%2FtmCoUsPyyB
The html attribute is what you want to render on your page.
We also have a PHP library you can use as well.
Hope that helps!
What I'm trying to do is get the exact look of the videos on the youtube homepage (image: click here) including the time-stamp.
If you look in the source code, you'll find a link to the image of the video, however, I can't quite figure out how to get the time-stamp of the video and format it exactly how youtube has it simply from a youtube link (in this case: http://www.youtube.com/watch?v=IpBNr-oNT1g). I take it this would be done with PHP, but how?
Thanks!
http://itwigle.com/twig/Capturing_video_thumbnails_with_PHP
is this what you're looking for?
I was looking at how Facebook makes external websites previews given on a URL shared by the user. The result is not just a thumbnail but actual text, an embedded video or an image depending on the link given. For example, if you post a link from a Wikipedia article, it displays text. If you post the link of a video from Dailymotion, it embeds it.
Is there a PHP/Javascript-Ajax approach to accomplish this? Any specific library for this purpose?
If there isn't, what's the best way server-side (in PHP if possible) solution for web scraping and displaying a thumbnail preview?
Facebook does this by looking for Open Graph meta tags. In the case of embedded videos, it's looking for the og:video tag.
If there aren't OG tags, it'll make a best guess.
I've been working with a couple of API's before like Vimeo, Dribbble and Twitter. Now I am trying out YouTube's API. But the complexity of the API gets me lost.
I've been going through parts of it and reading up on a couple of tutorials but can't seem to find what I want.
They say something about zend_gdata but I don't understand what that has to do with YouTube's API and can't seem to get it work either.
This is what I want to accomplish:
Get video data for each video from [playlist] by [user]:
Video poster (big thumbnail)
Title
Description
Embed code (iframe probably)
I am using PHP and prefer an output in JSON.
Can you guys point me out where to start (tutorial, which API, ...) to accomplish this rather simple task?
EDIT
Example for Vimeo: http://vimeo.com/api/v2/channel/52750/videos.json
Which URL can I CURL for YouTube to get al videos in a specified playlist?
From Data API Protocol site:
As noted in the previous section, each entry in a user's playlists feed contains a tag that specifies the URL for retrieving the list of videos in the playlist. The following example shows the URL for retrieving a playlist as that URL appears in a playlists feed entry:
<content type='application/atom+xml' src='http://gdata.youtube.com/feeds/api/playlists/8BCDD04DE8F771B2?v=2'/>
So the url is something like this:
http://gdata.youtube.com/feeds/api/playlists/PLAYLISTID?v=2
Update
For JSON format, add &alt=json GET parameter at the end of the url:
http://gdata.youtube.com/feeds/api/playlists/PLAYLISTID?v=2&alt=json
I am using a bespoke JQuery/PHP script which parses a Flickr feed using SimpliePie and outputs an image gallery.
I have instructed my client to upload there images into their flickr account.
The images are showing but the feed seems to be limiting to 20 images, however, there are 40 images in the stream.
I have checked the API and there doesn't seem to be any paramaters to change this.
Has anyone come across this before, can anyone help me tweak the feed so that it pulls all the images in the photostream?
Here is the Flickr Stream and feed...
http://www.flickr.com/photos/44280289#N04/
http://api.flickr.com/services/feeds/photos_public.gne?id=44280289#N04&lang=en-us&format=rss_200
It appears that they do limit it to the initial 20 photos on flickr
http://www.flickr.com/help/website/
Why do I only see 20 items in RSS
feeds?
Flickr only shows the latest 20 items
in a feed. Because of this, the first
time you connect to a feed you will
only see the most recent items. But if
your RSS reader saves items (as most
do) you will see more than 20 as the
items build up over time.
But you could potentially use the flickr api, particularly http://www.flickr.com/services/api/flickr.photosets.getPhotos.html
Which allows you to get more (You will need to get an API key however)
Edit:
Though I have not personally used it I have read/heard good things about http://phpflickr.com/ which is a flickr api wrapper for php 4 and 5
Edit 2:
Unfortunately I can not comment on your comment but if you take a look at this link from the flickr code blog
http://code.flickr.com/blog/2008/08/25/api-responses-as-feeds/
Some API responses can been provided as feeds so you could try using "&format=feed-rss_200" not sure if it includes getPhotos yet though.
It seems like you want to use the photosets.getPhotos api call. It will give you a maximum of 500 photos.
Here is an example which gives you the url of the photo in url_o
http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&extras=url_o&photoset_id=72157622766901612&api_key=[YOUR APIKEY HERE]
You need an api key to make it work.
You can also get the output as JSON directly by adding &format=json to the url.