巨量引擘-轉化回傳API

心无引擎,眼无流派發表於2024-11-22
$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
}

  

相關文章