0

can anyone help me to convert that curl comand line in a php curl code ? plz

curl -v --data "WSCommunityStringRW?2=1200ve50set&Submit=Submit" http://xxxxx/123 -u "admin:a1s2d3" --anyauth


Yes.I did something but ... not work :(

$api_url  = 'xxx/123';
$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, "admin:a1s2d3");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);

$data = array(
    'WSCommunityStringRW?2' => '1200ve50set',
    'Submit' => 'Submit'
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_close($ch);

1 Answer 1

3

Have you taken a look at the cURL pages in the PHP manual? It should contain everything you need for this.

Edit

In the code you've provided, curl_exec() is missing. If it doesn't work after calling curl_exec(), try looking at the output of curl_error().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.