如何将以下curl脚本转换为php curl脚本?

时间:2012-07-22 22:40:30

标签: php curl

任何人都可以帮我转换下面的curl代码到php curl脚本吗?

curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/xxx/SMS/Messages.xml' \
-d 'From=%2Byyyy' \
-d 'To=%2Bxxxx' \
-d 'Body=Dear%2C+Plz+wake+up%3B+it'\''s+time+4+SAHERI.%0D%0AYour+1+night+sacrifice+will+make+thousands+night+wonderful+by+the+grace+of+almighty+ALLAH.%0D%0A%0D%0A-biplob+(%2Bxxxxx)' \
-u xxx:yyy
最好的问候 MD Kamrul Hassan

1 个答案:

答案 0 :(得分:0)

您需要在卷曲手柄上设置的选项如下。

curl_setopt($ch, CURLOPT_URL, 'https://api.twilio.com/2010-04-01/Accounts/xxx/SMS/Messages.xml');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('From' => 'blah', 'To' => 'blih', 'Body' => 'Please wake up whatever'));
curl_setopt($ch, CURLOPT_USERPWD, 'username:password');