As this is my first post on this website, excuse me if I do some mistakes (like wrong title, forgetting something, etc).
I am developing PHP scripts (bots), and I'm using cURL to do this.
So I've coded a lot of things and I was always able to find the solution to my problems myself. Just to tell you that I DID search in MANY places before I write here.
So my problem is that I have to send an AMF request using PHP. I've gathered a lot of informations, tested a lot of codes, but none worked even if I got different results each time.
What I know is the request to send, where to send it, the referer for it, the method (POST/GET, POST in this case) to send it, but there is something I'm doing wrong.
I'll paste one of the hundreds of codes I've tested so that you can see the problem closer.
$url contains the url of the amf gateway
$postfields contains the amf request, I'm not sure if it needs to be placed here but I already tried to add it in the headers array
$referer contains the referer (obviously).
This isn't the WHOLE code but the values you need are already here.
function go_page($url, $postfields = array(), $referer = '')
{
global $ch;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_REFERER, $referer);
return curl_exec($ch);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-amf'));
$postfields = array('\x00\x03\x00\x00\x00\x01\x00\x16\x57\x68\x65\x65\x6c\x53\x65\x72\x76\x69\x63\x65\x2e\x73\x70\x69\x6e\x57\x68\x65\x65\x6c\x00\x02\x2f\x31\x00\x00\x00\x09\x0a\x00\x00\x00\x01\x02\x00\x01\x32');
echo go_page($url, $postfields, $referer);
This is the output : HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Sat, 12 Sep 2015 18:22:31 GMT Server: Apache/2.2.15 (CentOS) X-Powered-By: PHP/5.4.28 X-Cobalt: loaded Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8
.
Thanks in advance for your help...
Edit : I've already tried putting the request in the header array.