Created
February 24, 2020 13:49
-
-
Save Laim/716273db47604570c9a42d0bd5b8c8b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = "laim"; | |
$key = ""; | |
$type = "history"; //history or watching | |
// You need to register an API app here https://trakt.tv/oauth/applications to get the API Key (ClientID) | |
function traktAPI($user, $key, $type) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://api.trakt.tv/users/$user/$type"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_HEADER, FALSE); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
"Content-Type: application/json", | |
"trakt-api-version: 2", | |
"trakt-api-key: $key" | |
)); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
return json_decode($response, true); | |
} | |
var_dump(traktAPI($user, $key, $type)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment