I have a windows application using .net 4.
I am getting data from "WarGaming.Net" API.
Most of the data I get By HttpWebRequest and HttpWebResponse classes.
My url request is "http://cw.worldoftanks.eu/clanwars/maps/provinces/regions/1/?ct=json"
But I get "403 Forbidden".
I read this post about how to do it with java script https://github.com/thunder-spb/wot-api-description/issues/28#issuecomment-33958289
function getResp($parr) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://cw.worldoftanks.eu".$parr);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'Accept: application/json, text/javascript, text/html, */*',
'X-Requested-With: XMLHttpRequest'
)
);
curl_setopt($ch, CURLOPT_REFERER, "http://worldoftanks.eu/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$c_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
if (curl_getinfo($ch, CURLINFO_CONTENT_TYPE) == 'image/jpeg') {
$response = array();
$response['request_data']['error_message'] = w2u('Site returned JPEG, Maintanace maybe?');
$response = json_encode($response);
}
curl_close($ch);
return $response;
}
print_r( getResp('/clanwars/maps/provinces/regions/1/?ct=json') );
And I wonder how could I impliment this request to c# code with .net elements.
Thanks
RC