How to include 'data-urlencode' using php curl library How to include 'data-urlencode' using php curl library curl curl

How to include 'data-urlencode' using php curl library


What you're missing is

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));

where $payload is

$payload = [    'From' => '+122344444',    'To' => '+13101111111',    'Body'   => 'This is the body...'];


PHP Code:

$payload = [    'From' => '+122344444',    'To' => '+13101111111',    'Body'   => 'This is the body...'];$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_USERPWD, 'ACCOUNTID' . ':' . 'PASSWORD');curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));