PHP and thetvdb API

A place for developers to advertise their TheTVDB.com enabled app and get help from other developers with the API.
Post Reply
Schattenparker
Posts: 3
Joined: Fri Oct 04, 2019 1:56 am

Fri Oct 04, 2019 2:02 am

Hi

there is the https://api.thetvdb.com/swagger but i never worked with APIs an dont get the login done...

What must I do to get this working, for example: https://api.thetvdb.com/episodes/71663

Must I login with the API key first?
Are there some PHP example scripts which could help me?

I am a beginner working with PHP and API keys, please help me starting with this.
Schattenparker
Posts: 3
Joined: Fri Oct 04, 2019 1:56 am

Fri Oct 04, 2019 2:24 am

I made this simple script, but I dont get any response...

Code: Select all

function postcurl()
{
 $data = array(
    'apikey' => 'apikey',
	'id' => '71663'
);
 
$payload = json_encode($data);
 
// Prepare new cURL resource
$ch = curl_init('https://api.thetvdb.com/series');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
 
// Set HTTP Header for POST request 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($payload))
);
 
// Submit the POST request
$result = curl_exec($ch);
echo $result; 
// Close cURL session handle
curl_close($ch);
}
Schattenparker
Posts: 3
Joined: Fri Oct 04, 2019 1:56 am

Fri Oct 04, 2019 5:10 am

Nevermind. I got the login and the first few APIs working.

Please delete this thread.
Post Reply