Skip to content

Instantly share code, notes, and snippets.

@Laim
Created February 24, 2020 13:49
Show Gist options
  • Select an option

  • Save Laim/716273db47604570c9a42d0bd5b8c8b1 to your computer and use it in GitHub Desktop.

Select an option

Save Laim/716273db47604570c9a42d0bd5b8c8b1 to your computer and use it in GitHub Desktop.
<?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