Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

cURL, Wargaming API

$
0
0

Hi there,

 

I'm looking for a way how to obtain data for World of tanks account. I'm using Wargaming API and cURL.

 

Address example with data looks like this:

 

http://api.worldoftanks.eu/2.0/account/info/?application_id=d0a293dc77667c9328783d489c8cef73&account_id=509662813

 

With little php manual help I came up with (ehm copied) this.

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://api.worldoftanks.eu/2.0/account/info/?application_id=d0a293dc77667c9328783d489c8cef73&account_id=509662813");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);

$json = json_decode($output);
echo $json->{'data'}->{509662813}->{'statistics'}->{'all'}->{'battles'};

?>

It doesn't work but when I copy the contents of address to txt file and save it on my webhosting and then use the cURL - it works.

 

I tried to use CURLOPT_CONNECTTIMEOUT because sometimes it takes a long time to load a page from API. It didn't work either.

 

What am I missing here?


Viewing all articles
Browse latest Browse all 13200

Trending Articles