====== Working with RSS ====== Let's take a look at the Fediverse feed for the hashtag we're using for the coding meetup: https://glasgow.social/tags/coding This is formatted for a web browser. If we look at the source then we can see a line in the HTML that specifies how to access the data in format that can be used by programs ([[https://en.wikipedia.org/wiki/XML|XML]]). This is the [[https://en.wikipedia.org/wiki/RSS|RSS]] feed for that page: https://glasgow.social/tags/coding.rss RSS can be thought of as a **R**ich **S**ite **S**ummary, but it more popularly known as **R**eally **S**imple **S**yndication as it's often used to retrieve content from other sites to re-display (syndicate). If you provide lists of information on a web site it's good practice to also provide it as an RSS feed. ===== Reading RSS ===== Take a look at the RSS page in your browser: https://glasgow.social/tags/coding.rss It might not be very clear, but by comparing the version in the web browser to this RSS version you should be able to identify the content (it starts with the '''' tag and has a '''', ''<description>'', ''<link>'' etc). Here are the first two items (they content will change in your version based on when you view this page). <code xml> <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:webfeeds="http://webfeeds.org/rss/1.0"> <channel> <title>#coding These are public toots tagged with #coding. You can interact with them if you have an account anywhere in the fediverse. https://glasgow.social/tags/coding https://glasgow.social/packs/media/images/logo-fe5141d38a25f50068b4c69b77ca1ec8.svg 2b90d9 New status by neil https://glasgow.social/@neil/102489877960955931 https://glasgow.social/@neil/102489877960955931 Tue, 23 Jul 2019 08:43:48 +0000 <p>Coding from Scratch meetup tonight in <a href="https://glasgow.social/tags/theavalon" class="mention hashtag" rel="tag">#<span>TheAvalon</span></a> from 6:30pm! 26 signed up so far (without actually &apos;announcing&apos; the meetup&apos; - so it should be mostly people who have been before). See ya all there! <a href="https://glasgow.social/tags/coding" class="mention hashtag" rel="tag">#<span>coding</span></a></p> New status by Legomancer https://glasgow.social/@Legomancer/102464910703794081 https://glasgow.social/@Legomancer/102464910703794081 Thu, 18 Jul 2019 22:54:18 +0000 <p>Everyone has a preferred text editor that connects to AWS in different ways. I don’t know them all but this maybe the PHPStorm docs could be a starting point: <br /><a href="https://www.jetbrains.com/help/phpstorm/create-new-project-add-remote-server.html" rel="nofollow noopener" target="_blank"><span class="invisible">https://www.</span><span class="ellipsis">jetbrains.com/help/phpstorm/cr</span><span class="invisible">eate-new-project-add-remote-server.html</span></a> <br /><a href="https://glasgow.social/tags/coding" class="mention hashtag" rel="tag">#<span>coding</span></a> <a href="https://glasgow.social/tags/codingfromscratch" class="mention hashtag" rel="tag">#<span>codingfromscratch</span></a></p> ... The first two lines indicate the format of the data. The next line '''' is the main block of data to come (there can be multiple channels), it has a title, description etc. Then comes multiple '''' sections. These are the actual posts that make up the data. Take a moment to familarise yourself with the structure of the XML file. ===== Reading the RSS with PHP ===== Now we can write some code that reads this information and outputs it on your own page (more advanced uses might be to save it to a database or email you a summary daily etc) channel->item foreach($data->channel->item as $item_id=>$objItem) { echo "

".$objItem->description."

"; } ?>