vivo文档:https://open-ad.vivo.com.cn/doc/index?id=217
public function vivo(){ $accessToken = $this->request->param('accessToken'); $srcId = $this->request->param('srcId'); $cvType = $this->request->param('cvType'); $pageUrl = $this->request->param('pageUrl'); if (!$accessToken && !$srcId && !$cvType && !$pageUrl){ $this->error('参数错误'); } $current_time = microtime(true); // 获取当前时间的毫秒级时间戳,返回的是一个浮点数 $current_time_in_milliseconds = round($current_time * 1000); // 将浮点数的时间戳转换为整数形式的毫秒级时间戳 $data = [ 'dataList' => [[ "cvTime"=> $current_time_in_milliseconds, "cvType"=> $cvType, ]], "pageUrl" => $pageUrl, "srcId" => $srcId, "srcType" => 'web', ]; // $accessToken = "4e0fc22e085564a96a20d5a402348afd1f298c315ab85c9e09a30fe9a91e52d9"; $timestamp = $current_time_in_milliseconds; $nonce = time(); $url = "https://marketing-api.vivo.com.cn/openapi/v1/advertiser/behavior/upload?access_token=" .$accessToken . "×tamp=" . $timestamp . "&nonce=" .$nonce; $data_string = json_encode($data); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 忽略对证书的验证 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 不检查证书中是否设置域名 $result = curl_exec($ch); if ($result === false) { echo 'cURL Error: ' . curl_error($ch); } else { return $result; } curl_close($ch); }
标签:ch,setopt,vivo,time,curl,php,上传,CURLOPT From: https://www.cnblogs.com/ixiangang06/p/18045175