sa-mp HTTP( data[]..
#1

Hello there forum.
I was working with HTTP the other day and I came to notice data[] string was not findable everywhere in PHP.

I did an array_search() on get_defined_vars() but there was no match at all.

In sa-mp server, I've set my method to HTTP_POST, in case it matters.

What am I doing wrong that does sa-mp not send data[] or me not finding the result in php?

It is kinda shameful on the samp scripting team side that there is no proper documentation about this.
Also, who thought up of using HTTP as the function name for such a code? Of course ****** won't be able to help you then because of the nummerous results it will give you. Not to mention the same goes for the forum search forms.

The documentation is simply not completed about this.
After this is explained to me, I might update those pages if you grant me access to.

PHP has all data send to a webpage in it's variables. using a plain http server is not going to help much or change much for that matter.

The servers both work excellent and are hosted locally. The HTTP function works as supposed except for the DATA[]. It sends a request and receives an answer as well. It is exactly as I print in PHP.

I am a veteran PHP scripter and likewise for PAWN.

There is not a chance in the world I messed up any syntaxing whatsoever.
There is also no trace of sa-mp side variable bugs.

BOTTOM line: connections, servers, typo's are out of the question. There is no error whatsoever.

thanks for reading and perhaps answering.
Reply
#2

Well I just tried this and it worked fine

pawn Код:
#include <a_samp>
#include <a_http>

forward HTTPX(index, response_code, data[]);

main()
{
    HTTP(0,HTTP_POST, "127.0.0.1/test.php", "var=value&another=value2", "HTTPX");
}

public HTTPX(index, response_code, data[])
{
    printf("Response code: %d, Data: %s", response_code, data);
    return 1;
}
Test.php contents
PHP код:
<?php

print_r
($_POST);

?>
Output:

Код:
Response code: 200, Data: Array
(
    [var] => value
    [another] => value2
)
Hope this helps, thanks to Popz for giving me additional advice, as I wasn't sure myself
Reply
#3

Thank you very much, this makes sense.
I am trying this now, I assume it works.

You'll hear from me if it doesn't, which I doubt.

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)