0

The site that I will send him the Post uses cookies this way I got it from HTTP LIVE I want to put this data into the code I use

Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:44.0) Gecko/20100101 Firefox/44.0
Accept: */*
Accept-Language: ar,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/json;charset=UTF-8
X-Requested-With: XMLHttpRequest
x-csrf-jwt:XXXX
Referer: https://www.example.com
Content-Length: 1005
Cookie: XXXXXX guestSubmit
Connection: keep-alive

This is the code I use in the PHP file How to add the data requested by the site in this code to work when sending the Post to the server

function _curl($url,$post="",$usecookie = false,$put = false) {   

        $ch = curl_init(); 
        if($post) { 
                curl_setopt($ch, CURLOPT_POST ,1); 
                curl_setopt ($ch, CURLOPT_POSTFIELDS, $post); 
        } 
  if($put) curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
        curl_setopt($ch, CURLOPT_URL, $url); 
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
        curl_setopt($ch, CURLOPT_USERAGENT, "XXXXXXXXXX"); 
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Requested-With: XMLHttpRequest', 'XXXXXXXXX));
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
        if ($usecookie) { 
        curl_setopt($ch, CURLOPT_COOKIEJAR, $usecookie); 
        curl_setopt($ch, CURLOPT_COOKIEFILE, $usecookie);     
        } 

I did it this way but did not succeed to send the Post because of a mistake in cookies

function _curl($url,$post="",$usecookie = false,$put = false) {

    $ch = curl_init(); 
    if($post) { 
            curl_setopt($ch, CURLOPT_POST ,1); 
            curl_setopt ($ch, CURLOPT_POSTFIELDS, $post); 
    } 
    if($put) curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0"); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Requested-With: XMLHttpRequest', 'Accept: application/json, text/javascript, */*; q=0.01', 'Content-Type: application/json'));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
    if ($usecookie) { 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $usecookie); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, $usecookie);

Please help me in correcting and linking what the site requests with the code which I am using. Note I send the post by Jason code was converted to array

    $link = "wwwexample.com";


    $post = array (
  'data' => 
  array (
    'user' => 
    array (
      'first_name' => 'XXXX',
      'last_name' => 'XXXX',
 
    $s = _curl($link,$post,$cookie);

With this format

0 Answers0