user2876976
user2876976

Reputation: 5

Post curl data with php

I have a dashboard which I post data to display on.The dashbaord has multiple segments. I have an sql query which retrieves the data and loops through to push results. I want run the curl command below via php within this script. Can someone point me in the right direction? Or help. I have looked around a bit but im confused on how to get it to work.

Below is the what my php page will generate and this is what i would like to send via php using curl.

    curl -d '{ "auth_token" : "YOUR_AUTH_TOKEN" , "value" : "519" }' http://172.21.4.62:3030/widgets/Skin

Upvotes: 0

Views: 159

Answers (2)

CreatoR
CreatoR

Reputation: 1652

Try without any additional classes:

   $ch = curl_init('http://172.21.4.62:3030/widgets/Skin');
   $curlOptions = array(
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_FOLLOWLOCATION] => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => array("auth_token" => "YOUR_AUTH_TOKEN", "value" => "519"),
    );
   curl_setopt_array($ch, $curlOptions);
   $response = curl_exec($ch);
   curl_close($ch);

Upvotes: 1

Legionar
Legionar

Reputation: 7587

Its easier to use any curl class, f.e. curl.class.php

Usage:

$curl = new Curl();

$data = array("auth_token" => "YOUR_AUTH_TOKEN", "value" => "519");

$page = $curl->post("YOUR_URL_TO_CALL_VIA_CURL", $data);

Upvotes: 0

Related Questions