HTTP request not responding
#1

Hello, I'm trying to write a little script that ******s for some keywords, and returns the names and urls of the first 10 pages found.

I just started with this code:
PHP Code:
#include <a_samp>
#include <a_http>
forward OnHTTPResponse(indexresponse_codedata[]);
forward SendHTTPGet(indexurl[]);
main()
{
}
public 
OnRconCommand(cmd[])
{
    if(!
strcmp(cmd"http"))
    {
        
SendHTTPGet(42"www.******.com/search?q=hello+world");
    }
    return 
1;
}
public 
OnHTTPResponse(indexresponse_codedata[])
{
    
printf("OnHTTPResponse(%d, %d)"indexresponse_code);
    switch(
response_code)
    {
        case 
200..299// OK
        
{
            new 
text[1028];
            
format(text1028"%s"data);
            
printf("Data: ");
            
printf(data);
        }
        case 
300..399// Redirect 
        
{
            new 
url[512];
            new 
text[1028];
            
format(text1028"%s"data);
            new 
start_idx strfind(text"http://"true0) + 7;
            new 
end_idx strfind(text"\""truestart_idx);
            
strmid(urltextstart_idxend_idx);
            
printf("Redirecting...");
            
SetTimerEx("SendHTTPGet"500false"is"indexurl);
        }
    }
}
public 
SendHTTPGet(indexurl[])
{
    
printf("Sent request to %s"url);
    
HTTP(indexHTTP_GETurl"""OnHTTPResponse");

But I get

Code:
[14:26:32]   Filterscript 'webBrowser.amx' loaded.
[14:26:32] Number of vehicle models: 0
Console input: http
[14:26:36] Sent request to www.******.com/search?q=hello+world
[14:26:36] OnHTTPResponse(42, 302)
[14:26:36] Redirecting...
[14:26:36] Sent request to www.******.it/search?q=hello+world&amp;gws_rd=cr&amp;ei=N17pVuXHCsHOOPqUt5AB
Then OnHTTPResponse is not being called again.

Please help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)