mercredi 22 mai 2019

How to write following JS server requst code in PHP

I have a JS code and i want to write the same request in PHP

I want the php request code with the header and data but request should be send from the php, from the server

var text { "ai": "2958052", "ci": "740", "gi": "1094", "userip": "userzadasd", "firstname": "asdo", "lastname": "casda", "email": "adbnas@adas.ocm", "password": "dasdasasda@gmail.com", "phone": "123456789", "prefix": "966" } let mjson = JSON.stringify(text); var http = new XMLHttpRequest(); var url = 'https://platform.lmglobal.club/api/signup/procform'; http.open('POST', url, true); //Send the proper header information along with the request http.setRequestHeader('x-trackbox-username', 'xxxxxxxxxxxx'); http.setRequestHeader('x-trackbox-password', 'xxxxxxxxxx'); http.setRequestHeader('x-api-key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); http.setRequestHeader('Content-Type', 'application/json'); http.send(mjson); http.onreadystatechange = function () {//Call a function when the state changes. if (http.readyState == 4 && http.status == 200) { alert(http.responseText); } }




Aucun commentaire:

Enregistrer un commentaire