views:

602

answers:

1
$description = "some test data and url";
$description .="http://www.mydata.com?test=1&user=4&destination=645&source=stackoverflow";

curl_setopt($sch, CURLOPT_URL, "myserverurl");
curl_setopt($sch, CURLOPT_HEADER, 0);             
curl_setopt($sch, CURLOPT_POST, true);
curl_setopt($sch, CURLOPT_RETURNTRANSFER , 1);
curl_setopt($sch, CURLOPT_POSTFIELDS, "orgid=$orgid&description=$description&external=1");
curl_setopt ($sch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($sch, CURLOPT_SSL_VERIFYPEER, 0);

when i check on the server (myserverurl).

I can see the description field like

"some test data and url http://www.mydata.com?test=1".

i lost the description after '&'

yes , we can encode the url before sending with curl, but i do not have access to decode the url again on that third party api server

A: 

What if you urlencode the value of each parameter you are sending ?

You don't have to worry about decoding on the other side : it is standard way of sending data through GET / POST

Something like :

curl_setopt($sch, CURLOPT_POSTFIELDS, 
    "orgid=" . urlencode($orgid) 
    . "&description=" . urlencode($description) 
    . "&external=1"
);

And if this doesn't work, try with rawurlencode ? (there is a difference for spaces, if I remember correctly)

Pascal MARTIN
Or you could use http://php.net/http_build_query which is far more convenient.
Salaryman
indeed ; much better / easier ; and less error-prone
Pascal MARTIN