巨量引擘-转化回传API

$v_clickid = isset($clickid) ? $clickid : '';
if(!empty($v_clickid)){
	//Api回调
	$ch = curl_init();
	$cur_time = microtime(true);
	$cur_time = round($cur_time * 1000);
	$data = array(
		'event_type' => 'form', 
		'context' => array(
			"ad"=>array(
				"callback"=>$v_clickid
			)
		),
		"timestamp"=> $cur_time
	);
	$data = json_encode($data);
	$url = 'https://analytics.oceanengine.com/api/v2/conversion';
	
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
			'Content-Type: application/json; charset=utf-8',
			'Content-Length: ' . strlen($data)
		)
	);
	
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	$response = curl_exec($ch); //接口返回信息
	$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);//接口返回标识 200 为正确
	//var_dump($httpCode);exit;
	//Api回调-end
}

  

posted @ 2024-11-22 08:07  心无引擎,眼无流派  阅读(10)  评论(0编辑  收藏  举报