This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
mastodon_rss [2021/06/13 00:13] neil created |
mastodon_rss [2021/06/14 20:16] (current) neil |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Mastodon RSS Bookmarks ====== | ====== Mastodon RSS Bookmarks ====== | ||
- | Mastodon considers your bookmark list to be private information. I'm happy to share mine. Plus, I wanted a way to add any bookmarks I make there into a 'Bookmark' category in my RSS reader (which is also where my phone and browser bookmarks go). | + | Mastodon considers your bookmark list to be private information. I'm happy to share mine. Plus, I wanted a way to add any bookmarks I make there into a 'Read later' category in my RSS reader (which is also where my phone and browser bookmarks go). |
This was pretty simple, I create a PHP file that gets the latest 20 bookmarks (default API endpoint ''/api/v1/bookmarks'') and takes an access token from your mastodon 'development' admin page. | This was pretty simple, I create a PHP file that gets the latest 20 bookmarks (default API endpoint ''/api/v1/bookmarks'') and takes an access token from your mastodon 'development' admin page. | ||
Line 9: | Line 9: | ||
<?php | <?php | ||
header('Content-Type: text/xml'); | header('Content-Type: text/xml'); | ||
- | $bearer = "get your token from the development page in the mastodon web client settings"; | + | $bearer = "get your access token from the development page in the mastodon web client settings"; |
+ | $instance = "glasgow.social"; | ||
$headers = [ | $headers = [ | ||
'Authorization: Bearer '.$bearer, | 'Authorization: Bearer '.$bearer, | ||
Line 15: | Line 16: | ||
$ch_bookmarks = curl_init(); | $ch_bookmarks = curl_init(); | ||
- | curl_setopt($ch_bookmarks, CURLOPT_URL, "https://glasgow.social/api/v1/bookmarks"); | + | curl_setopt($ch_bookmarks, CURLOPT_URL, "https://$instance/api/v1/bookmarks"); |
curl_setopt($ch_bookmarks, CURLOPT_RETURNTRANSFER, true); | curl_setopt($ch_bookmarks, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($ch_bookmarks, CURLOPT_HTTPHEADER, $headers); | curl_setopt($ch_bookmarks, CURLOPT_HTTPHEADER, $headers); | ||
Line 39: | Line 40: | ||
foreach($bookmarks as $k=>$v) { | foreach($bookmarks as $k=>$v) { | ||
- | //echo $v['url']."\n"; | ||
- | //echo $v['content']."\n"; | ||
$xml_item[$k] = "\n\t<item> | $xml_item[$k] = "\n\t<item> | ||
<title>{$v['card']['title']}</title> | <title>{$v['card']['title']}</title> |