Need help with API


InsomniacsBuilds wrote 17 days ago:

Hi there,

What a Great site, this is. :) I'm looking for an API. What I can use on my Wordpress site.

I don't need one to show Movie and Show releases as my premium Theme already does this.

I am looking for a channel API where i can show whats on TV. Does TVMaze do this with a monthly package for just showing Live TV Schedule?

Any help would be greatly appreciated.

Many Thanks

Kirk

www.insomniacs.w


InsomniacsBuilds wrote 15 days ago:

Hi David,

Thanks for your reply. I have subscribed to the Silver package.

I'm just not sure where i find the API to add a TV Schedule of 'Whats On' on my website. I've got my API. I just don't know how to get the one for the Live TV Schedule.

Many Thanks.


InsomniacsBuilds wrote 14 days ago:

I'm not sure how i get the information for my API to just show Live TV Schedule. Then i can highlight picks of the week.

I'm using Wordpress for my site. But am not too clued up on setting it up. I'm so glsd i found a servive that offers this

Regards.


gazza911 wrote 14 days ago:

Just to clarify, the schedule API endpoint is in the public API and doesn't require the premium (User) API.

For wordpress, you can use wp_remote_get() to retrieve the data from the API - you'll find various tutorials for it online.

If you want to store it in a database, you can just schedule something to run each day and update it.


InsomniacsBuilds wrote 14 days ago:

Hi Gazza,

Thank You very kindly for helping clear that up for me. Sadly, I'm terrible with anything when it comes to databases, and doing things server side.

I will look to see if i can hire someone to add it for me. I will carry on with the Premium as i may add Shows and stuff further down the line.

Thank You very much, dor your advise it will help me loads. Your a top man.

Regards


InsomniacsBuilds wrote 14 days ago:

gazza911 wrote:
Just to clarify, the schedule API endpoint is in the public API and doesn't require the premium (User) API.

For wordpress, you can use wp_remote_get() to retrieve the data from the API - you'll find various tutorials for it online.

If you want to store it in a database, you can just schedule something to run each day and update it.

Hi Gazza,

Sorry to bother you. But do you know anywhere i can get help with adding this? Or pay someone to add it for me.

Thanks very much for your advise. I appreciate it.


InsomniacsBuilds wrote 14 days ago:

gazza911 wrote:
Just to clarify, the schedule API endpoint is in the public API and doesn't require the premium (User) API.

For wordpress, you can use wp_remote_get() to retrieve the data from the API - you'll find various tutorials for it online.

If you want to store it in a database, you can just schedule something to run each day and update it.

I can add the plugin and the API code. I just don't know how i set it up so it updates itself.


gazza911 wrote 14 days ago:

InsomniacsBuilds wrote:
I can add the plugin and the API code. I just don't know how i set it up so it updates itself.

You can use the following:

wp_schedule_event( time(),'daily','your_event');

add_action('your_event', 'your_function');

your_function_2()

This means that if someones visits your site and it's been a day since it's last been ran, it will run your_function.

What you're going to want to do in your_function is:

1. Set a column in the DB to say that you're synchronising

2. Load the data from the API

3. Add the data to the database and set the column to synced

In your_function_2() :

1. Check if the state column is synced

2a. If it's synchronising then you'll either have to wait or return old data

2b. If it's synced then you can return the data

I've never done anything in wordpress so I can't really advise more than that, but if you search for the functions I've mentioned, you should be able to find tutorials online.


InsomniacsBuilds wrote 13 days ago:

Hi Gazza,

Thank-You very much for the help. I think i will hire a Freelancer though as i don't like to mess with stuff server side as I'm very inexperienced with it all.

I've joined the Silver premium so i think i will add the Movies and Shows too if that's possible. I just don't have a clue what I'm doing to be honest. It's really hard to find any tutorials on how to add the TV Schedule and i haven't a clue where to start with the Movies and Shows. The way my site is set up i can add Movies and shows. But it takes up a lot of space with images etc. So this would be perfect. It's just getting it set up that I'm having difficulty with. I really appreciate your advise. Your a top man.


InsomniacsBuilds wrote 13 days ago:

I have searched for WP_Remote_Get Plugin, but i can't seem to find it anywhere. Wordpress is showing the following plugins: https://wordpress.org/plugins/tags/wp_remote_get/

Will this woork the same way do you think? Sorry to ask so many questions, im going to have an attempt at getting it set up and will searh some tutorials. First i will try nd get the schedule set up, then i will ttry the Movies and Shows.

Really appreciate your advise, it's great.


InsomniacsBuilds wrote 13 days ago:

gazza911 wrote:
Just to clarify, the schedule API endpoint is in the public API and doesn't require the premium (User) API.

For wordpress, you can use wp_remote_get() to retrieve the data from the API - you'll find various tutorials for it online.

If you want to store it in a database, you can just schedule something to run each day and update it.

I'm just reading up online, i thought that wp_remote_get was a plugin lol.. That's how inexperienced i am. My apologies, for sounding so stupid lol. I will get there in the end (I hope)


InsomniacsBuilds wrote 13 days ago:

Hi,

I'm sorry to ask so many questions, but im a little confused with one thing.. Once we add the End points URLS, and then set up the wp_schedule_event

the wp_remote_get will return data as json format, what do we need to do with that data that is my question

How do we then add/Display the data into a page? Or onto the site? Does any code or anything like that need adding do you know?

My apologies for all the questions, i just want to understand it properly before i add them Thanks


gazza911 wrote 13 days ago:

You need to use json_decode (function) so that you can access it as an object with properties.

After that it's just formatting it however you want to display it.

P.S. TVmaze only has TV shows, not movies (except made for TV ones that are related to a series).


InsomniacsBuilds wrote 12 days ago:

Hi Gazza, is this right?

UK Schedule: https://insomniacs.website/tv-schedule-gb/

US Schedule: https://insomniacs.website/tv-schedule-usa/

Just can't get the channel to show. It's a shame that TVMaze, don't offer a premium option, As it's not showing which channel it's on. And if anyone wants any info, and click to see channel name, or Description, it drives traffick away from the site.

Thanks for all your help your a star.


gazza911 wrote 12 days ago:

InsomniacsBuilds wrote:
Hi Gazza, is this right?

UK Schedule: https://insomniacs.website/tv-schedule-gb/

US Schedule: https://insomniacs.website/tv-schedule-usa/

Just can't get the channel to show. It's a shame that TVMaze, don't offer a premium option, As it's not showing which channel it's on. And if anyone wants any info, and click to see channel name, or Description, it drives traffick away from the site.

Thanks for all your help your a star.

You can get almost all of that information from the public API.

The network and webChannel properties are objects that contain their own properties.

So something like:

$network = $decoded->{'network'};
$networkName = $network->{'name'};

(You'll need validation as either the network or web channel can be null)

The only thing you can't get is the channel's description.

As for the show description, you'll need to make more calls to the API as detailed here: https://www.tvmaze.com/api#shows

If you want, you can use the _links self property which already contains the show's API link.


InsomniacsBuilds wrote 11 days ago:

Hi Gazza,

Thank-You very much indeed. You've been amazing and helped me so much. I think it's right now?

https://insomniacs.website/tv-schedule-gb/

https://insomniacs.website/tv-schedule-usa/

As you said the images when listing is clicked doesn't show. But isn't really a huge problem. I'm going to keep my premium API even though, i don't use it. As i'm at least giving something back for the TV Schedule if that makes sense.

Can you think of anything that we've missed?

I really appreciate all your advise. Top top man.

Regards


gazza911 wrote 11 days ago:

InsomniacsBuilds wrote:
Can you think of anything that we've missed?

I see that you're using the show image to identify what show it is.

That could be an issue if we don't have an image for the show (or episode) as you wouldn't know what it is.

Other than that it seems fine.


InsomniacsBuilds wrote 10 days ago:

Thanks again Gazza..

I've just seen the Networks, and Web Channels. Do they work via the API? I hired a freelancer to add the TV Schedule.

I'm hoping the Networks and Web Channels I can add myself. As would save me so much time having to individually add them. And create Tables and just featured content. Where as if i can add the Networks, would make things so much easier. I've searched but can't find any tutorials or guides on how to add to wordpress.

Again, thank you so much for all your help.


gazza911 wrote 10 days ago:

InsomniacsBuilds wrote:
Thanks again Gazza..

I've just seen the Networks, and Web Channels. Do they work via the API? I hired a freelancer to add the TV Schedule.

They're a bit limited in the API.

You can't simply get a list of them; they're just meant to identify what a show aired on.

Even if you looped through to get all of them, you can't do anything with that information as you can't get a list of shows that aired on the network.