Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

CW section #28

Closed
huncyrus opened this issue Feb 1, 2014 · 5 comments
Closed

CW section #28

huncyrus opened this issue Feb 1, 2014 · 5 comments

Comments

@huncyrus
Copy link

huncyrus commented Feb 1, 2014

Anyone else can reach the cw section? ( http://cw1.worldoftanks.eu/clanwars/maps/provinces/regions/1/?ct=json ) Ive got bad gateway / timeout as answare.

@Satariall
Copy link
Contributor

See 504 too. May be incorrect cache saved?(

@thunder-spb
Copy link
Owner

Works for me.

function getResp($parr) {

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://cw1.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);
        }
//      echo $c_type;
        curl_close($ch);
        return $response;

}

print_r( getResp('/clanwars/maps/provinces/regions/1/?ct=json') );

Not working without proper REFERER

@huncyrus
Copy link
Author

huncyrus commented Feb 3, 2014

Yup, thx, now they change little thing on cw code, and without referer or bad referer they show just a timeout.

@huncyrus huncyrus closed this as completed Feb 3, 2014
@thunder-spb
Copy link
Owner

Well, I always send referer and this header to any requests, so I didnot faced such issues atall :) Just in case...

@Rcman99
Copy link

Rcman99 commented Feb 18, 2014

Do you know how to impliment it in c# ?

I tryed :

        string url = @"http://cw1.worldoftanks.eu/clanwars/maps/provinces/regions/1/?ct=json";
        string text = "";


        HttpWebRequest request =(HttpWebRequest) WebRequest.Create(url);
        request.ContentType = @"application/json, text/javascript, text/html, */*";
        request.Method = "POST";
        request.Accept = @"application/json, text/javascript, text/html, */*";
        //string authInfo = "usr:pwd";
        request.Headers["X-Requested-With"] = "XMLHttpRequest";
        request.Referer = @"http://worldoftanks.eu/";


        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

But I get Timeout 503.

Any idea ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants