SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Closed Thread
 
Thread Tools Display Modes
Old 08/08/2012, 01:25 AM   #1
Shaneisace
Big Clucker
 
Join Date: Jan 2012
Posts: 93
Reputation: 20
Default the HTTP_GET (Website side)

Hello there everyone could someone explain to me how the website side works I've seen people use it for Radio Stations and other cool things.

But on the SA-MP Wiki it doesn't really show much detail on the website side as i've understood how it works Script side but i want to make it on file on my webhost

Example I'm thinking of making a music station that brings a list so i can update it without re-starting the server

but i'm confused on how to grab this information from a .php if someone could help get me started that would be great example of what i want to do is below:

test.php?listsongs=1 i want to make it like that but unsure how to start it.

I've have knowledge with PHP just not even to make it like the URL above

Can someone help me get started (I'm not asking you to make me one just start one) thanks for reading.
Shaneisace is offline  
Old 08/08/2012, 03:07 AM   #2
AustinJ
Big Clucker
 
Join Date: Jul 2011
Posts: 145
Reputation: 15
Default Re: the HTTP_GET (Website side)

For the php side of the script you wound't really need a get varible to be ran though the url. Just have your php page list your stations.

So in Pawn you would call your page via
pawn Code:
HTTP(0, HTTP_GET, "yourdomain.com/yourscript.php", "", "HttpResult");
Then you want to make the 'HttpResult' public callback.
pawn Code:
public HttpResult(index, response_code, data[])
{
    // data[] is your PHP script ouputed source code.
}

Hope that is enough information to get you started.
__________________
AustinJ is offline  
Old 08/08/2012, 03:21 AM   #3
Shaneisace
Big Clucker
 
Join Date: Jan 2012
Posts: 93
Reputation: 20
Default Re: the HTTP_GET (Website side)

Quote:
Originally Posted by AustinJ View Post
For the php side of the script you wound't really need a get varible to be ran though the url. Just have your php page list your stations.

So in Pawn you would call your page via
pawn Code:
HTTP(0, HTTP_GET, "yourdomain.com/yourscript.php", "", "HttpResult");
Then you want to make the 'HttpResult' public callback.
pawn Code:
public HttpResult(index, response_code, data[])
{
    // data[] is your PHP script ouputed source code.
}

Hope that is enough information to get you started.
i understand that but I'm confused on how to use like this test.php?listsongs=1 and after it lists it when they click on one i can show information using the same php like test.php?listsongs=%d&info do you get where I'm going with it?
Shaneisace is offline  
Old 08/08/2012, 03:29 AM   #4
AustinJ
Big Clucker
 
Join Date: Jul 2011
Posts: 145
Reputation: 15
Default Re: the HTTP_GET (Website side)

You would call a php page with a get variable like such
pawn Code:
new string[128];
format(string, 128, "yourdomain.com/yourscript.php?listfor=%i", stationid);
HTTP(0, HTTP_GET, string, "", "HttpResult");

And for the php page you would do something like this.
Code:
if(isset($_GET["listfor"])) // List Songs
{
	$stationid = $_GET["listfor"];
}
else // List Stations
{
	
}
__________________
AustinJ is offline  
Old 08/08/2012, 03:47 AM   #5
Shaneisace
Big Clucker
 
Join Date: Jan 2012
Posts: 93
Reputation: 20
Default Re: the HTTP_GET (Website side)

Quote:
Originally Posted by AustinJ View Post
You would call a php page with a get variable like such
pawn Code:
new string[128];
format(string, 128, "yourdomain.com/yourscript.php?listfor=%i", stationid);
HTTP(0, HTTP_GET, string, "", "HttpResult");

And for the php page you would do something like this.
Code:
if(isset($_GET["listfor"])) // List Songs
{
	$stationid = $_GET["listfor"];
}
else // List Stations
{
	
}
Thanks this is what i'm sort of thing i was looking for Now i can take time to learn it cheers
Shaneisace is offline  
Old 08/08/2012, 04:08 AM   #6
AustinJ
Big Clucker
 
Join Date: Jul 2011
Posts: 145
Reputation: 15
Default Re: the HTTP_GET (Website side)

Your welcome, I didn't want to tell you how to do it in great detail since that would ruin the fun of learning & scripting it
__________________
AustinJ is offline  
Old 08/08/2012, 04:17 AM   #7
Shaneisace
Big Clucker
 
Join Date: Jan 2012
Posts: 93
Reputation: 20
Default Re: the HTTP_GET (Website side)

Quote:
Originally Posted by AustinJ View Post
Your welcome, I didn't want to tell you how to do it in great detail since that would ruin the fun of learning & scripting it
Its coming back to me now, if i do test.php i got it to return "Something went wrong" but if i do test.php?Listsongs=1 it returns "Line 1" even though this is just done by the Web Browser lol :P

I would REP you but i don't have 50 posts

EDIT: Never mind it said i reped you lol

EDIT: I get response error 6 now, i guess it means "HTTP_ERROR_MALFORMED_RESPONSE" do you know what that means?
Shaneisace is offline  
Old 08/08/2012, 04:28 AM   #8
AustinJ
Big Clucker
 
Join Date: Jul 2011
Posts: 145
Reputation: 15
Default Re: the HTTP_GET (Website side)

What is shown in the web browser is the value of data[]. If you write click a page and do view source that is what data[] will be, from what I understand. Taking this into effect if you are going to use a web host with ads this may not work since the code for the ads will be returned to the data[] string also.

EDIT: As for `HTTP_ERROR_MALFORMED_RESPONSE` I have no clue to what that means out of my many years of scripting web based languages.
__________________
AustinJ is offline  
Old 08/08/2012, 04:44 AM   #9
Shaneisace
Big Clucker
 
Join Date: Jan 2012
Posts: 93
Reputation: 20
Default Re: the HTTP_GET (Website side)

well the only thing sent as Data[] will be "Line 1" as its just a blank .php with the PHP code

here's the code

PHP Code:
<?
if (isset($_GET['listsongs'])) // List Songs
{
    echo 
"Line 1";

}
else 
// List Stations
{
    echo 
"Something went wrong";
}
?>
Shaneisace is offline  
Old 08/08/2012, 04:59 AM   #10
AustinJ
Big Clucker
 
Join Date: Jul 2011
Posts: 145
Reputation: 15
Default Re: the HTTP_GET (Website side)

Hmm... I am not sure why. I haven't really used the http functions in pawn before so I am not 100% sure about them. I know at one point I had a script and my php page echoed out a line to the console saying that it executed and when there was an ad on the page I saw the ad's code along with my echo'ed output,
__________________
AustinJ is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Translation of text using HTTP_GET and ****** translate $$$PiMp Scripting Help 50 03/12/2013 01:32 PM
I need help with HTTP_GET mineralo Scripting Help 3 16/06/2012 09:15 AM
HTTP_GET vection Help Archive 1 18/10/2010 02:51 PM


All times are GMT. The time now is 04:54 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.