HTTP not responding(code: 1)
#1

code(from sa-mp wiki , just for testing):
Code:
forward MyHttpResponse(index, response_code, data[]);
 
public OnPlayerCommandText(playerid, cmdtext[])  
{
    if(!strcmp("/hello",cmdtext,true))
    {
// URL: ftp://gintars@safg.wu.lt/hello.txtnl67b1...6.94899063        HTTP(playerid, HTTP_GET, "gintars@safg.wu.lt/hello.txt", "", "MyHttpResponse");
        return 1;
    }
    return 0;
}
 
public MyHttpResponse(index, response_code, data[])
{
    // In this callback "index" would normally be called "playerid" ( if you didn't get it already :) )
    new
        buffer[ 128 ];
    if(response_code == 200) //Did the request succeed?
    {
        //Yes!
        format(buffer, sizeof(buffer), "The URL replied: %s", data);
        SendClientMessage(index, 0xFFFFFFFF, buffer);
    }
    else
    {
        //No!
        format(buffer, sizeof(buffer), "The request failed! The response code was: %d", response_code);
        SendClientMessage(index, 0xFFFFFFFF, buffer);
    }
}
current php version :5.5
Reply
#2

bump
Reply
#3

bump(the last one)
Reply
#4

Return code 1 means HTTP_ERROR_BAD_HOST, probably because the URL you've specified isn't valid (it looks like an email account, actually). As far as I know, URLs can't have '@' on the domain name (****** Chrome even corrected it for me, I've tried to access that website but it removed everything from @ to back), so you should check it.

Also, you can check all the return codes meaning on the wiki - https://sampwiki.blast.hk/wiki/HTTP
Reply
#5

Im getting error 6 now, which seems to be website issue, but code working with a free website.
Big thanks to you, it was really important for me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)