簡體   English   中英

如何使用這個 POST CURL 到 PHP

[英]How to use this POST CURL into PHP

EXCLAMATION_MARK='!'
curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json \
--data-urlencode "From=whatsapp:$$$$$" \
--data-urlencode "Body=Hello there$EXCLAMATION_MARK" \
--data-urlencode "To=whatsapp:+$$$$$" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

大家好,我如何在 PHP 代碼中使用這個 curl 代碼? 我已經嘗試了很多選擇,但沒有成功

你會做類似的事情。

$TWILIO_ACCOUNT_SID="whatever";
$TWILIO_AUTH_TOKEN="FLEH";
$ch = curl_init("https://api.twilio.com/2010-04-01/Accounts/{$TWILIO_ACCOUNT_SID}/Messages.json");
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,array(
    "From"=>"whatsapp:\$\$\$\$\$",
    "Body"=>"Hello there!",
    "To"=>"whatsapp:+\$\$\$\$\$"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN");
$response = curl_exec($ch);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM