1

am struggling with this for weeks now..

what is the correct way to send HTML-code with cURL ??

I tried base46_encode() and also json_encode() .. but on the reciever-side I always get a unuseable string.. how would i encode a html-code for sending?

$ch = curl_init($url);
$payload = json_encode( $data );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));                
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );                
$result = curl_exec($ch);
curl_close($ch);

1 Answer 1

1

You can pass an array directly to cURL as documented on PHP.net, try turn the payload data into an array and send directly into cURL or via HTTP Build Query.

HTTP Build Query

Possible duplicate of: PHP + curl, HTTP POST sample code? and Post HTML content via cURL

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.