How to post request without curl

How to post request without curl

Asked on January 19, 2021 in php.

i have usedĀ file_get_contents().

The PHP manual has a niceĀ example here. This is just copy past from the manual:

$postdata = http_build_query(
    array(
        'var1' => 'some content',
        'var2' => 'doh'
    )
);
$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);
$context  = stream_context_create($opts);
$result = file_get_contents('http://example.com/submit.php', false, $context);
on January 19, 2021.
Add Comment
1 Answer(s)

    Here is one of the example

    <?php
    $postdata = http_build_query(
    
    array(
    
    'call_status' => $call_status,
    
    'talk_time' => $talktime,
    
    'dialler_id' => $dialerid,
    
    'current_time' => $current_time,
    
    'lead_id' => $lead_id,
    
    'call_type' => inbound,
    
    'queue_wait' => $queuewait,
    
    'disposition' => $disposition,
    
    'phone_no' => $phone,
    
    'call_id' => $call_id,
    
    'call_check' => 1
    
    )
    );
    $opts = array('http' =>
    
    array(
    
    'method' => 'POST',
    
    'header' => 'Content-type: application/x-www-form-urlencoded',
    
    'content' => $postdata
    
    )
    
    );
    $context = stream_context_create($opts);
    
    $result = file_get_contents('http://blog.eduguru.in/updateData', false, $context);
    echo $result;
    
    echo $postdata;
    ?>
    
    Answered on June 5, 2021.
    Add Comment

    Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.