ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Post data in EE template page is not delivered via PHP CURL

June 15, 2011 2:34am

Subscribe [1]
  • #1 / Jun 15, 2011 2:34am

    jkumar

    2 posts

    I am trying to make a post via a PHP CURL request from an external application; however, the post data is not being delivered to the EE template. It works when I just use a simple html form post; however, with curl…the post variable is null! How can I fix this?

    In my template page I have this code:

    $something = $this->EE->input->post(“something”);

    //the something code is returning null
    echo $something;

    The php curl code is shown below:

    $url = ‘http://localhost/training/api/get-content2’;
    $url = ‘http://localhost/training/api/get-content2’;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Accept: application/json’, ‘Content-Type: application/json’));
    //$data = array(‘something’ =>  urlencode(‘foofoofoo’));
    curl_setopt($ch, CURLOPT_POSTFIELDS, ‘something=something’);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt( $curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_HEADER, 0);     
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);       
    $output = curl_exec($ch); 
    $output = stripslashes($output);
    $output = str_replace(’{if logged_in}’, ‘’, $output);
    $output = json_decode($output, true);

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases