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);
Milan Chheda
  • 7,851
  • 3
  • 18
  • 35
css
  • 51
  • 8

1 Answers1

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

Enoch
  • 624
  • 5
  • 15