我正在嘗試通過 cURL 用 PHP 發布這個腳本;
<script async=1 type=text/javascript src=//trackcmp.net/convert?actid=10000&e=[email protected]&c=1&v=100&r=&u=https://www.website.com/></script>
我嘗試了以下 cURL;
$conversion_value = isset($args['conversion_value']) ? $args['conversion_value'] : "";
if(empty($conversion_value)){
return false;
}
$window_location_href = "www.website.com";
$document_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "";
$trackcmp_email = '[email protected]';
$trackcmp_conversion = '1';
$trackcmp_conversion_value = $conversion_value;
$trackcmp = [];
$trackcmp['src'] = 'https://trackcmp.net/convert';
$trackcmp['params'] = array('actid' => '10000', 'e' => urlencode($trackcmp_email), 'c' => $trackcmp_conversion, 'v' => $trackcmp_conversion_value, 'r' => $document_referrer, 'u' => $window_location_href);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $trackcmp['src']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $trackcmp['params']);
$headers = array();
$headers[] = 'Content-Type: text/javascript';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
我是否忘記了一些 cURL 明智的事情,或者它只是不起作用?
我希望最終通過某種 webhook 將這些值發布到所述 URL。
編輯:顯然我一直在考慮這個問題。我標記為“答案”的回復為我解決了這個問題。
uj5u.com熱心網友回復:
這就是你的請求對 trackcmp.net 服務器的樣子
Content-Length: 618
Content-Type: text/javascript; boundary=------------------------9923620be574b58c
Accept: */*
BODY=
--------------------------9923620be574b58c
Content-Disposition: attachment; name="actid"
10000
--------------------------9923620be574b58c
Content-Disposition: attachment; name="e"
info%40email.com
--------------------------9923620be574b58c
Content-Disposition: attachment; name="c"
1
--------------------------9923620be574b58c
Content-Disposition: attachment; name="v"
--------------------------9923620be574b58c
Content-Disposition: attachment; name="r"
--------------------------9923620be574b58c
Content-Disposition: attachment; name="u"
--------------------------9923620be574b58c--
洗掉帖子欄位。
添加curl_setopt($ch, CURLOPT_HTTPGET, true);
使用此 URL:
https://trackcmp.net/convert?actid=10000&[email protected]&c=1&v=100&r=&u=https://www.website.com
接收到的 GET 資料看起來應該是這樣的:
$_SERVER['QUERY_STRING']
actid=10000&[email protected]&c=1&v=100&r=&u=https://www.website.com
所以這是你的卷曲代碼:
$headers = array();
$headers[] = 'Content-Type: text/javascript';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, 'https://trackcmp.net/convert?actid=10000&[email protected]&c=1&v=100&r=&u=https://www.website.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, true);
$response = curl_exec($ch);
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/521083.html
標籤:phphtml卷曲
