Posted in simplepie php
3342
4:33 am, September 29, 2022
 

simple pie get link from enclosure item in simplepie rss feed

i had an item like this in a rss feed, and i wanted to grab the enclosure url, took me a while to figure this out for some reason even though the solution is quite simple. 

PHP

<item>
<title>title</title>
<link>https://kruxor.com/</link>
<dc:creator>
<![CDATA[ KRUXOR ]]>
</dc:creator>
<enclosure url="https://kruxor.com/logo.jpg" type="image/jpeg"/>
<category>
<![CDATA[ Cat ]]>
</category>
<description>
<![CDATA[ Text ]]>
</description>
<content:encoded>
<![CDATA[ <p>Long Text</p> ]]>
</content:encoded>
<pubDate>Thu, 29 Sep 2022 03:10:07 GMT</pubDate>
<guid isPermaLink="true">https://kruxor.com/</guid>
</item>

Just use get_enclosure and then get_link rather than trying to access the object returned by the get_enclosure function. 

$game_news->image = $item->get_enclosure()->get_link();

..

View Statistics
This Week
61
This Month
182
This Year
689

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
“If you just sit and observe, you will see how restless your mind is. If you try to calm it, it only makes it worse, but over time it does calm, and when it does, there’s room to hear more subtle things. You see so much more than you could see before. It’s a discipline; you have to practice it.”
Steve Jobs
Random CSS Property

range

When defining custom counter styles, the range descriptor lets the author specify a range of counter values over which the style is applied. If a counter value is outside the specified range, then the fallback style will be used to construct the representation of that marker.
range (@counter-style) css reference