Are you wondering how to use the TasteKid API with PHP? I guess, I can help you. You will see a screenshot below. It's the screenshot of my Tastekid Bot on Telegram messaging app. Maybe you're already using the Telegram but even I should say that you should use it.
Telegram is a messaging app like Whatsapp. My bot is a virtual Telegram user for help about suggestions like Tastekid to users who uses the Telegram. But, you don't need to know the Telegram for this article. Because, It is just a simple example for to see to what can you do with the API of Tastekid.
You can find my Tastekid bot with @tastekidbot username/link on Telegram.
Update 5 Apr 2017:
I've published Tastekidbot on GitHub, YAY!
Here is a screenshot:
We will pull the results from the Tastekid API with PHP's
file_get_contents function. You may want to use the CURL instead file_get_contents for this but I think, my prefer is easiest.
All you need is here. That is the Tastekid API documentation. You must register an account then request an access key from Tastekid. You will use this access key for your requests.
2. Variables and request url
Did you get an access key? If yes, continue. If not, take one. Then, define your variables for your request url.
<?php $access_key = "yourkey-2w58438834"; $query = "Kill Bill"; $type = "movie"; $info = "1"; $limit = "3"; ?>
They're your variables for your request url. Here is what they're;
$access_key = Your access key requested from Tastekid access key page.
$query = Search query. It can be a movie or show name, band or artist name, author or director name. Also, you can specify this query's every element like that:
movie:Star Trek or multiple element seperated by comma:
Star Wars, show: Star Trek. You can use these for specify an element's type: show:, movie:, author:, band:, book:, game:.
$type = Query type, specifies the desired type of results. It can be one of the following: music, movies, shows, books, authors, games. If not specified, the results can have mixed types.
$info = When set to 1, additional informations provided for the recommended item. Default is 0.
$limit = Maximum number of the recommendations. Default is 20.
Define the request url
If everything is clear until now, let's continue. Here is our url for the request:
You will replace all [xxx] strings with your variables. Here is an example:
<?php $access_key = "252085-Tastekid-J3VTYH9H"; $query = "Kill Bill"; $type = "movie"; $info = "1"; $limit = "3"; $request_url = "https://www.tastekid.com/api/similar?q=".urlencode($query)."&type=".$type."&info=".$info."&limit=".$limit."&k=".$access_key; $get_results = file_get_contents($request_url); $get_results = json_decode($get_results, TRUE); print_r($get_results); ?>
You will see an output like in the screenshot below:
Then, you can use these arrays to process your result. That is all! If you have any question, you can use the comment section below. All your questions are welcome. Ta-ta!