
Sign up to save your podcasts
Or
This show has been flagged as Clean by the host.
This is Episode 4 of the Plain Text Programs Podcast hosted at Hacker
My blog and this podcast were my inspiration for writing the Embed
It came to mind that it would be nice to be able to display the
So here's my idea.
I want to use mastodon toots as a comment thread for my blog
At the bottom of the blog post I want to embed the toot and the
I can pull the toot id from the embed code.
Then I want to make a database query to get all the replies to that
Then I can generate the embed codes needed to show the toot and all
I'm a mysql guy, not postgres. Also a Mastodon newb.
I want to know how to get the reply ids for a toot.
Any help, links, etc?
End quote.
I immediately got responses from some programmers expressing interest
I did some research based on their suggestions. I had a good night's
Mastodon is so great.
I had this idea last night and fiddled around with it long enough to
So I made a post on Mastodon and almost immediately got help.
I found some good info on the Mastodon API.
I wake up this morning to more help and I found out about using curl
Then a musician friend of mine who I've been following since before
And I've got a plan.
End quote.
So credit where credit is due.
The programmers, gamers, and musicians helping me were:
Jeff the GenX Alien
EcksDy
Malin
and
Wayne Myers
Now, I've known Wayne Myers since before I was ever on Mastodon. We
He sent some links in a couple of comments to other blogs that were
Jeff the GenX Alien gave me some significant technical help. And I
Use tootcli to learn everything you need to know about the inner
https://github.com/ihabunek/toot
Whatever the API supports so does toot.
End quote.
So I looked into tootcli and the Mastodon API and I realized that I
So, thanks Jeff.
My second clue came from EcksDy. And I quote.
I've got some help too. Using the Mastodon API and curl in php it
End quote.
So then I started to research using curl in PHP to retrieve json data
I set up a testbed and Malin chimed in with test results. He
That's why Mastodon is so great! Way better than consulting an AI
So I had my work cut out for me. Here is where this program is like
I said I had a plan. This was my plan.
Write a PHP program that will generate a webpage that can be embedded
Get that link from the Mastodon embed code for the parent post.
Use the API to retrieve the data associated with the parent post
Then generate the page by inserting the appropriate data into
That's kind of a broad framework but it certainly seemed doable. And
So first I wanted to make the API call so I could look at the
I found this video by Alejandro AO.
How to easily create cURL API requests in PHP (Wordpress, Laravel,
He recommended that you use curl in the terminal to test your API
My first time consuming stumbling block was what I call the problem
There are some great documents detailing the syntax for API calls
And where you are supposed to insert an id they show that as :id.
Like an idiot I thought the colon was part of the syntax, not as they
Anyway I couldn't get it to work so I searched around until I found
Now I was able to make API calls using curl in the terminal. I copied
So I made my API call from my program. The Curl-to-PHP code returned
$obj = json_decode($result, true);
And I could use the print_r command to look at that data.
print_r($obj);
I immediately put the print_r command at the bottom of my program
So I fumbled around for a while before I figured out that I would
Accessing json data is reading an array. So easy peasy or maybe not.
$id = $obj['descendants'][$i]['id'];
Like I said, it looks easy now. Needless to say it took some head
I used to be a mason and people would always ask me how I learned
So then I generated the embed code to display each post and it
So I scrolled down and examined the json data and I found the url
This still didn't work. After staring at the json data for a while
Now that I had become enlightened it was easy to notice that the url
So by using the url data in the embed I have less string handling and
I went to bed and in the morning I made this post. And I quote. >
So the data structure I needed is called a multidimensional array or
In terms of a database table it is two columns and a bunch of
In terms of PHP arrays it's an array where each element is an array
I initialize the array with the parent post.
$ids = array(array($id,$url));
You can see the nested arrays in the code.
Then I add items to the array like this.
$ids[] = array($id,$url);
I access an array item like this.
The 1 refers to the second element of the array because programmers
Then using the url and the domain that I captured from the GET
Which worked but the posts weren't displayed in chronological order.
So I had to sort the multidimensional array on the id. Which isn't as
So I found this article on stackoverflow called
How do I sort a multidimensional array by one of the fields of
It had a two line solution that I modified to work with my array.
And now all my posts were in chronological order.
Stack Overflow code is licensed CC BY which is one way compatible
My first post quoted above was posted on Friday, October 25, at 8:40
On Monday, October 28 at 8:52 PM I wrote, "Here's the blog post proof
Three days from "I have an idea" to "working code". That wasn't all I
And I have worked on the code a little bit today. And I will in the
Also posts from different servers look different. Sometimes the
I decided to embrace that as a feature rather than a bug with the
I have uploaded Embed Mastodon Threads to home.gamerplus.org. At my
The program is 46 lines of code with 11 lines of comments including
This has been a long podcast, certainly longer than most of my
Throughout the whole project I was posting to my threads on Mastodon
It was a rush!
So this is not exactly a plain text program because it uses a
Most of my plain text programs are web apps or web pages. This one is
And it is simple to use. All you have to be able to do is copy the
I have a help page for using Embed Mastodon Threads in the same
If you would rather download the code and install your own instance
If you have questions you can reply to a thread on Mastodon or email
My Plain Text Blog
Embed Mastodon Threads Help Page
Codeberg Repository
From Jeff the GenX Alien
How to easily create cURL API requests in PHP (Wordpress,
Curl-to-PHP
Playing with public data - Mastodon documentation
Status - Mastodon documentation
Context - Mastodon documentation
How do I sort a multidimensional array by one of the fields of
Embed Mastodon Threads Hosted On Gamerplus
Gamer+DBN Mastodon server
Provide feedback on this episode.
4.2
3434 ratings
This show has been flagged as Clean by the host.
This is Episode 4 of the Plain Text Programs Podcast hosted at Hacker
My blog and this podcast were my inspiration for writing the Embed
It came to mind that it would be nice to be able to display the
So here's my idea.
I want to use mastodon toots as a comment thread for my blog
At the bottom of the blog post I want to embed the toot and the
I can pull the toot id from the embed code.
Then I want to make a database query to get all the replies to that
Then I can generate the embed codes needed to show the toot and all
I'm a mysql guy, not postgres. Also a Mastodon newb.
I want to know how to get the reply ids for a toot.
Any help, links, etc?
End quote.
I immediately got responses from some programmers expressing interest
I did some research based on their suggestions. I had a good night's
Mastodon is so great.
I had this idea last night and fiddled around with it long enough to
So I made a post on Mastodon and almost immediately got help.
I found some good info on the Mastodon API.
I wake up this morning to more help and I found out about using curl
Then a musician friend of mine who I've been following since before
And I've got a plan.
End quote.
So credit where credit is due.
The programmers, gamers, and musicians helping me were:
Jeff the GenX Alien
EcksDy
Malin
and
Wayne Myers
Now, I've known Wayne Myers since before I was ever on Mastodon. We
He sent some links in a couple of comments to other blogs that were
Jeff the GenX Alien gave me some significant technical help. And I
Use tootcli to learn everything you need to know about the inner
https://github.com/ihabunek/toot
Whatever the API supports so does toot.
End quote.
So I looked into tootcli and the Mastodon API and I realized that I
So, thanks Jeff.
My second clue came from EcksDy. And I quote.
I've got some help too. Using the Mastodon API and curl in php it
End quote.
So then I started to research using curl in PHP to retrieve json data
I set up a testbed and Malin chimed in with test results. He
That's why Mastodon is so great! Way better than consulting an AI
So I had my work cut out for me. Here is where this program is like
I said I had a plan. This was my plan.
Write a PHP program that will generate a webpage that can be embedded
Get that link from the Mastodon embed code for the parent post.
Use the API to retrieve the data associated with the parent post
Then generate the page by inserting the appropriate data into
That's kind of a broad framework but it certainly seemed doable. And
So first I wanted to make the API call so I could look at the
I found this video by Alejandro AO.
How to easily create cURL API requests in PHP (Wordpress, Laravel,
He recommended that you use curl in the terminal to test your API
My first time consuming stumbling block was what I call the problem
There are some great documents detailing the syntax for API calls
And where you are supposed to insert an id they show that as :id.
Like an idiot I thought the colon was part of the syntax, not as they
Anyway I couldn't get it to work so I searched around until I found
Now I was able to make API calls using curl in the terminal. I copied
So I made my API call from my program. The Curl-to-PHP code returned
$obj = json_decode($result, true);
And I could use the print_r command to look at that data.
print_r($obj);
I immediately put the print_r command at the bottom of my program
So I fumbled around for a while before I figured out that I would
Accessing json data is reading an array. So easy peasy or maybe not.
$id = $obj['descendants'][$i]['id'];
Like I said, it looks easy now. Needless to say it took some head
I used to be a mason and people would always ask me how I learned
So then I generated the embed code to display each post and it
So I scrolled down and examined the json data and I found the url
This still didn't work. After staring at the json data for a while
Now that I had become enlightened it was easy to notice that the url
So by using the url data in the embed I have less string handling and
I went to bed and in the morning I made this post. And I quote. >
So the data structure I needed is called a multidimensional array or
In terms of a database table it is two columns and a bunch of
In terms of PHP arrays it's an array where each element is an array
I initialize the array with the parent post.
$ids = array(array($id,$url));
You can see the nested arrays in the code.
Then I add items to the array like this.
$ids[] = array($id,$url);
I access an array item like this.
The 1 refers to the second element of the array because programmers
Then using the url and the domain that I captured from the GET
Which worked but the posts weren't displayed in chronological order.
So I had to sort the multidimensional array on the id. Which isn't as
So I found this article on stackoverflow called
How do I sort a multidimensional array by one of the fields of
It had a two line solution that I modified to work with my array.
And now all my posts were in chronological order.
Stack Overflow code is licensed CC BY which is one way compatible
My first post quoted above was posted on Friday, October 25, at 8:40
On Monday, October 28 at 8:52 PM I wrote, "Here's the blog post proof
Three days from "I have an idea" to "working code". That wasn't all I
And I have worked on the code a little bit today. And I will in the
Also posts from different servers look different. Sometimes the
I decided to embrace that as a feature rather than a bug with the
I have uploaded Embed Mastodon Threads to home.gamerplus.org. At my
The program is 46 lines of code with 11 lines of comments including
This has been a long podcast, certainly longer than most of my
Throughout the whole project I was posting to my threads on Mastodon
It was a rush!
So this is not exactly a plain text program because it uses a
Most of my plain text programs are web apps or web pages. This one is
And it is simple to use. All you have to be able to do is copy the
I have a help page for using Embed Mastodon Threads in the same
If you would rather download the code and install your own instance
If you have questions you can reply to a thread on Mastodon or email
My Plain Text Blog
Embed Mastodon Threads Help Page
Codeberg Repository
From Jeff the GenX Alien
How to easily create cURL API requests in PHP (Wordpress,
Curl-to-PHP
Playing with public data - Mastodon documentation
Status - Mastodon documentation
Context - Mastodon documentation
How do I sort a multidimensional array by one of the fields of
Embed Mastodon Threads Hosted On Gamerplus
Gamer+DBN Mastodon server
Provide feedback on this episode.
1,971 Listeners
117 Listeners
5,938 Listeners
283 Listeners
265 Listeners
89 Listeners
43 Listeners
154 Listeners
35 Listeners
7,864 Listeners
36 Listeners
21 Listeners
314 Listeners
92 Listeners
20 Listeners