PDA

View Full Version : HTTP Response error 1 (BAD HOST)


Admigo
12/10/2013, 10:10 AM
Hello,

I am trying to fix a youtube searcher with results but its giving me error Error: Request failed! Try again later. [Response code: 1] ( BAD HOST)
CMD:youtube(playerid, params[])
{
if(sscanf(params, "s[128]", params))
{
SendClientMessage(playerid, COLOR_BLUE, "Usage: /youtube < Name of video to search >");
SendClientMessage(playerid, COLOR_ORANGE, "Function: It will search and reproduce the specified youtube song.");
return 1;
}
Request_Type[playerid] = 0;
if(strcmp(params, Last_Search[playerid], true))
{
format(Last_Search[playerid], 128, "%s", params);
new assist[256];
format(assist, sizeof(assist), "http://admigos.net/curl.php?limit="#MAX_RESULTS"&linkid=http://www.youtube.com/results?search_query=%s", params);
for(new i = 35; i < strlen(assist); i++) if(assist[i] == ' ') assist[i] = '?';
HTTP(playerid, HTTP_GET, assist, "", "MyYoutubeHttpResponse");
return 1;
}
ShowResultsWindow(playerid);
return 1;
}

forward MyYoutubeHttpResponse(index, response_code, data[]);
public MyYoutubeHttpResponse(index, response_code, data[])
{
if(response_code == 200)
{
new assist[128];
new f = strfind(data, ">", true, 0), t = 0, offset = 0;
while(f != -1 && t < MAX_RESULTS)
{
strmid(assist, data, f + 1, f + 12);

//by Nightmare[TR] (http://forum.sa-mp.com/showthread.php?t=370450) - You can change this address to your own website host:
format(Results_Links[index][t], 128, "http://element-samp.net/youtube.php?videoid=%s", assist);

strmid(assist, data, f + 15, strfind(data, "<", true, f + 15));
format(Results_Names[index][t], 128, "%s", assist);
t++;
offset = f + 16;
f = strfind(data, ">", true, offset);
}
Videos_Found[index] = t;
ShowResultsWindow(index);
}
else
{
format(Dialog_String, sizeof(Dialog_String), "Error: Request failed! Try again later. [Response code: %d]", response_code);
SendClientMessage(index, COLOR_RED, Dialog_String);
}
return 1;
}

The php file is in my public_html folder at my host and the file have 644 rights.
Is there any way to fix this?

Admigo