Facebook fanpage Rss encoding error - php

This is my fanpage: https://www.facebook.com/kidsvideo.us
And here is my rss url: https://www.facebook.com/feeds/page.php?format=atom10&id=1433882270183943
There is error encoding when use this rss, I use php simplepie and tried feedburner with the same error: feeds.feedburner.com/KidsVideosFacebookWall
Any solution?

The solution is: Facebook use html entity in the xml. Simple use html_entity_decode() to decode the "error content".

Related

how to validate RSS feed URL in simplpie library

I want to validate RSS feed URL before its process for parsing. I am using willvincent/feeds library for this.
$feed = Feeds::make($rssurl);
$items = $feed->get_items();
I am parsing RSS feed like above.
So how can validate the RSS feed URL before parsing using willvincent/feeds library.
'willvincent/feeds' is just a service provider for Laravel.
You should refer to SimplePie documentation, and use the error() method to check if url throws errors. This method holds the error description.
$feed = Feeds::make('http://some-bogus-feed-url');
if($feed->error()){
//handle the feed error
}

How to can I parse with Jsoup in Android?

I cannot get the data of this with Jsoup. It can connect if I use this:
Connection connection = Jsoup.connect("http://android-forum.hu/feed.php");
But if I want to get the site data I got this exeption:
org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=application/atom+xml; charset=UTF-8, URL=http://android-forum.hu/feed.php
I use this code:
Document doc = Jsoup.connect("http://android-forum.hu/feed.php").get();
So I want to get the page data. How to get it?
The UnsupportedMimeTypeException is thrown when the minetype of the response is not supported.
You can use ignoreContentType(true) to let Jsoup ignore minetype, try
Document doc = Jsoup.connect("http://android-forum.hu/feed.php")
.ignoreContentType(true)
.get();
(call it before .get)

How to implement the SimplePie force_feed function in WordPress

When I try to parse a specific RSS feed using the native RSS widget for WordPress I receive the following error:
RSS Error: A feed could not be found at
http://trustbox.trustpilot.com/r/harringtonbrooks.co.uk.xml. A feed
with an invalid mime type may fall victim to this error, or SimplePie
was unable to auto-discover it.. Use force_feed() if you are certain
this URL is a real feed.
I have validated the feed using the http://validator.w3.org/feed/ and it states that the feed is valid. I belive that the mime type is also correct for the feed - type="application/rss+xml"
After consulting the SimplePie documentation this code is suggested as the fix - however I am clueless as to where this code would actually be implemeted within the WordPress installation.
$feed = new SimplePie();
$feed->set_feed_url('MY FEED URL');
$feed->force_feed(true);
$feed->init();
$feed->handle_content_type();
echo $feed->get_title();
Alternatively are there any other suggestions for getting this RSS feed to actually be parsed by the reader?

check youtube video is embeddable <yt:noembed> via xml

I have following link http://gdata.youtube.com/feeds/api/videos/tYMYv1zsAxE and it return an xml file in which is located noembed tag in case the video is not embeddable.
i want to create a loop on list of videos to check which is embeddable and which is not.
Based on your clarification, it sounds like you're asking a question about parsing XML. Here's an alternative: get back JSON, and parse that. You can make a request like
http://gdata.youtube.com/feeds/api/videos/tYMYv1zsAxE?v=2&alt=jsonc&prettyprint=true
and then look at the data->accessControl->embed element within the JSON response.
Or, you know, just parse and access the YouTube API XML exactly like you'd parse the XML from any other source. There's nothing magic going on with the YouTube API XML.
$vidID = "tYMYv1zsAxE";
$url="http://gdata.youtube.com/feeds/api/videos/$vidID?v=2&alt=jsonc&prettyprint=true";
$json = file_get_contents($url, true);
$json_output = json_decode($json);
echo $json_output->data->accessControl->embed;
Simple way to check if youtube video is embeddable.
Thanks to #Jeff Posnick

sending xml file from php to an android application

I am trying to send an xml file as a httpresponse to a post from an android application.
I understood how to send data from a php page here.
Is it possible to send a xml file as a response?
Or do I have to send the content of xml file as a string and parse it in the application?
If it is possible, How do I read the file in my application, so that I can parse it for information?
Thank you.
Send the xml from the server as a string. And in the application side parse the string either using SaxParser, XmlPullParser or DomParser. These are all commonly used.
This is a tutorial from IBM which gives an overview of parsing in android
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
Of course you can. just you can send the xml format type in a php source file.
like following code. sorry for writing [ instead of < or > as this post doesn't allow tag elements.
echo '[?xml version="1.0" encoding="utf-8"?]';
echo '[something][/something]';

Categories