Try 30 days of free premium.

Error using User API

Cecile wrote 5 years ago: 1

Hi,

I'm just starting to look into the user API, and i'm stuck.

I tried to use curl in PHP, and I've got a 'false' response. This is my script :

$login = 'cecile';

$password = SOMETHING;

$url = 'https://api.tvmaze.com/v1/user/episodes?show_id=82';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");

$result = curl_exec($ch);

curl_close($ch);

var_dump($result);

What did I do wrong ?

Cecile wrote 5 years ago: 1

Yes, of course :)

In my code, I've replaced [SOMETHING] with my API key.

On the apidoc page, it's working fine


david wrote 5 years ago: 1

Or try:

curl_setopt($ch, CURLOPT_VERBOSE,true);

Cecile wrote 5 years ago: 1

It worked with SSL_VERIFYPEER.

Thanks to you both !


david wrote 5 years ago: 1

Note that this is not a secure solution as it pretty much renders the HTTPS useless. Instead, you should make sure your system has an uptodate CA bundle installed in a path where curl can find it.

Cecile wrote 5 years ago: 1

Is that a problem if I am only running it locally ?

I'm trying to implement my 'acquire-list' that I long for :D


david wrote 5 years ago: 1

Not a big problem in that case. Just don't distribute it to the public like that :)

Try 30 days of free premium.