curl_sslversion_tlsv1 php,Sendgrid PHP使用未定义的常量CURL_SSLVERSION_TLSv1_2

我正在使用Sendgrid API通过PHP通过HTTP发送电子邮件.这是我的代码:

$url = 'https://api.sendgrid.com/';

$user = 'USER';

$pass = 'PASSWORD';

$params = array(

'api_user' => $user,

'api_key' => $pass,

'to' => 'TARGET',

'subject' => 'Kami Menanti Anda',

'from' => 'noreply@kompetisiindonesia.com',

);

$params['html'] = 'html message';

$params['text'] = $params['html'];

$request = $url.'api/mail.send.json';

// Generate curl request

$session = curl_init($request);

// Tell curl to use HTTP POST

curl_setopt ($session, CURLOPT_POST, true);

// Tell curl that this is the body of the POST

curl_setopt ($session, CURLOPT_POSTFIELDS, $params);

// Tell curl not to return headers, but do return the response

curl_setopt($session, CURLOPT_HEADER, false);

// Tell PHP not to use SSLv3 (instead opting for TLS)

curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);

curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

// obtain response

$response = curl_exec($session);

curl_close($session);

// print everything out

print_r($response);

但我收到此错误消息:

Notice: Use of undefined constant CURL_SSLVERSION_TLSv1_2 – assumed

‘CURL_SSLVERSION_TLSv1_2’ in

/opt/lampp/htdocs/oprek/sendgrid/sendviahttp.php on line 28

有人知道发生了什么吗?

解决方法:

看起来您的计算机上可能安装了过时的CURL版本.

CURL_SSLVERSION_TLSv1_2 (integer) Available since PHP 5.5.19 and 5.6.3

标签:sendgrid,php,curl

来源: https://codeday.me/bug/20190829/1764610.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值