$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://translation.googleapis.com/v3beta1/projects/${PROJECT_ID}/locations/global:detectLanguage");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n mimeType: 'text/plain',\n content: 'Omnia Gallia est divisa in tres partes'\n}");
curl_setopt($ch, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Authorization: Bearer $(gcloud auth application-default print-access-token)';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $result;
}
curl_close ($ch);
1 个回复
CMSYOU - CMS企业网站定制专家
赞同来自:
//关闭SSL验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// 创建curl资源
$ch = curl_init();
// 设置url
curl_setopt($ch, CURLOPT_URL, "https://www.test.com");
// 将Transfer作为字符串返回
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 关闭SSL验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
// 执行并输出
$output = curl_exec($ch);
// 查看错误
$error = curl_error($ch);
echo $error;
// 释放curl资源
curl_close($ch);
最新活动:2021-02-24 15:33
浏览:1076 次
关注:1 人
Copyright © 2008-2024 CMSYOU - 互助问答社区 - 粤ICP备10060801号-3 RSS Feed
欢迎加入QQ群(346494585) “让我们一起来学习CMS建站吧!”
要评论问题请先登录或注册