Jump to content

Creating a REST API


RyanMinor

Recommended Posts

I want to create a REST  API for my website. What I want to do is to display advertisements from my database on websites that I sell to clients. Their website will call my database for advertisements to display on their websites. Also, I am performing a site validity check where the client's site would send the site URL, site name, and site token to my database for validation. If it returns false then the site will not display as it will be invalid according to my database. I've been Googling this topic all day, but cannot seem to get my head around it. I want to set an API key on my website so that not just anybody can be querying my database. For the advertisement query, no parameters need to be sent from the client websites to my database. Can anyone offer some advice on how to do this?

Link to comment
https://forums.phpfreaks.com/topic/251078-creating-a-rest-api/
Share on other sites

It was late when I posted this. I now realize a far better option would be to not expose the API at all and let the API return a path to an image. Something like:

 

$image_url = file_get_contents('http://my-api-website.com/adverts-api.php?host=the-host-website&session=' . $somesessionid);
echo '<img src="', $image_url, '" alt=""/>';

Link to comment
https://forums.phpfreaks.com/topic/251078-creating-a-rest-api/#findComment-1288635
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.