the HTTP_GET (Website side) -
Shaneisace - 08.08.2012
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.
Re: the HTTP_GET (Website side) -
AustinJ - 08.08.2012
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.
Re: the HTTP_GET (Website side) -
Shaneisace - 08.08.2012
Quote:
Originally Posted by AustinJ
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?
Re: the HTTP_GET (Website side) -
AustinJ - 08.08.2012
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
{
}
Re: the HTTP_GET (Website side) -
Shaneisace - 08.08.2012
Quote:
Originally Posted by AustinJ
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
Re: the HTTP_GET (Website side) -
AustinJ - 08.08.2012
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
Re: the HTTP_GET (Website side) -
Shaneisace - 08.08.2012
Quote:
Originally Posted by AustinJ
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?
Re: the HTTP_GET (Website side) -
AustinJ - 08.08.2012
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.
Re: the HTTP_GET (Website side) -
Shaneisace - 08.08.2012
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";
}
?>
Re: the HTTP_GET (Website side) -
AustinJ - 08.08.2012
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,