如何使用印象信标读取服务器调用数据(像素)
How to Use Impression Beacons to Read Server Call Data (Pixel)
我需要对使用像素向服务器发送服务器信息有所了解。我们使用 validclick,他们说他们的信标必须发送到 1x1 透明图像。从我所做的一切来看,我找不到关于使用 1x1 gif 接收数据的基本 "how to"。
我现在拥有的是一个带有我的 gif 的 .php 文件,然后是我的脚本,用于从 URL 读取查询字符串并将其插入我们的数据库。
<?php
header('Content-Type: image/png');
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=');
$conversion = $_SERVER['QUERY_STRING'];
$info = explode("&", $conversion);
$variables = array('id' => '', 'ts' => '', 'slotid' => '', 'q' => '', 'u' => '', 'ty' => '', 'nq' => '', 'nr' => '');
foreach ($info as $i) {
$temp = explode("=", $i);
$variables[$temp[0]] = $temp[1];
}
// Connect to the database
try {
// Info to connect to the database
$servername = "****";
$dbusername = "****";
$password = "****";
$dbname = "****";
// To connect to the database please
$conn = new mysqli($servername, $dbusername, $password, $dbname);
if ($conn->connect_error) {
die('Connect Error (' . $conn->connect_errno . ') ' . $conn->connect_error);
}
} catch (mysqli_sql_exception $e) {
throw $e;
}
$variables['ts'] = str_replace("%", " ", $variables['ts']);
echo $variables['ts'];
$insert = "INSERT INTO validclickimpressions (id, ts, slotid, q, u, ty, nq, nr) " .
"VALUES ('" . $variables['id'] . "', '" .
$variables['ts'] . "', '" .
$variables['slotid'] . "', '" .
$variables['q'] . "', '" .
$variables['u'] . "', '" .
$variables['ty'] . "', '" .
$variables['nq'] . "', '" .
$variables['nr'] . "')";
if(!$conn->query($insert)){
die('There was an error running the query "' . $insert . '" [' . $conn->error . ']');
}
$conn -> close;
?>
我想我只是缺少对这些信标如何工作的一些基本金属理解。 validclick 应该将信息发送到此 URL,并将这些变量附加到 URL 的末尾。所以这在我访问测试 URL(例如:http://www.mywebsite.com/beacon_url/impression_beacon.php?id=1234&ts=2018-01-12%14:44:30&slotid=1234&q=1234&u=1234&ty=1234&nq=1234&nr=1234)时有效,但是当我们收到印象时似乎没有将数据插入我们的 table。
编辑:我认为我的问题是我的 php 与我的形象不符。我认为页面只能包含图像。但是,如果我将它从页面中删除,我不知道如何从信标接收数据。
希望此 php 代码能帮助任何人在将来尝试设置印象信标。此代码适用于 Inuvo。
/*
* YPA Impression BEACON END POINT
*/
// *** lowercase all param names ***
$_REQUEST = array_change_key_case($_REQUEST);
// Default impression args
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; // = coresponding impression ID
$ts = isset($_REQUEST['ts']) ? $_REQUEST['ts'] : null; // = unix timestamp of impression
$slotid = isset($_REQUEST['slotid']) ? $_REQUEST['slotid'] : null; // = location in page
$q = isset($_REQUEST['q']) ? $_REQUEST['q'] : null; // = keyword
$u = isset($_REQUEST['u']) ? $_REQUEST['u'] : null; // = landing page url
$ty = isset($_REQUEST['ty']) ? $_REQUEST['ty'] : null; // = affid
$nq = isset($_REQUEST['nq']) ? $_REQUEST['nq'] : null; // = number of ads requested for that ad unit / slot (New)
$nr = isset($_REQUEST['nr']) ? $_REQUEST['nr'] : null; // = number of ads returned for that ad unit / slot (New)
// Your custom args defined in your YPA code block
// serveBeacon:"x=1&y=2&z=3", //string of key value pairs you want to hit this end point.
$x = isset($_REQUEST['x']) ? $_REQUEST['x'] : null;
$y = isset($_REQUEST['y']) ? $_REQUEST['y'] : null;
$z = isset($_REQUEST['z']) ? $_REQUEST['z'] : null;
// write to your storage/db here
// Return image 1x1 gif content
header('Content-Type: image/gif');
echo base64_decode('R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==');
我需要对使用像素向服务器发送服务器信息有所了解。我们使用 validclick,他们说他们的信标必须发送到 1x1 透明图像。从我所做的一切来看,我找不到关于使用 1x1 gif 接收数据的基本 "how to"。
我现在拥有的是一个带有我的 gif 的 .php 文件,然后是我的脚本,用于从 URL 读取查询字符串并将其插入我们的数据库。
<?php
header('Content-Type: image/png');
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=');
$conversion = $_SERVER['QUERY_STRING'];
$info = explode("&", $conversion);
$variables = array('id' => '', 'ts' => '', 'slotid' => '', 'q' => '', 'u' => '', 'ty' => '', 'nq' => '', 'nr' => '');
foreach ($info as $i) {
$temp = explode("=", $i);
$variables[$temp[0]] = $temp[1];
}
// Connect to the database
try {
// Info to connect to the database
$servername = "****";
$dbusername = "****";
$password = "****";
$dbname = "****";
// To connect to the database please
$conn = new mysqli($servername, $dbusername, $password, $dbname);
if ($conn->connect_error) {
die('Connect Error (' . $conn->connect_errno . ') ' . $conn->connect_error);
}
} catch (mysqli_sql_exception $e) {
throw $e;
}
$variables['ts'] = str_replace("%", " ", $variables['ts']);
echo $variables['ts'];
$insert = "INSERT INTO validclickimpressions (id, ts, slotid, q, u, ty, nq, nr) " .
"VALUES ('" . $variables['id'] . "', '" .
$variables['ts'] . "', '" .
$variables['slotid'] . "', '" .
$variables['q'] . "', '" .
$variables['u'] . "', '" .
$variables['ty'] . "', '" .
$variables['nq'] . "', '" .
$variables['nr'] . "')";
if(!$conn->query($insert)){
die('There was an error running the query "' . $insert . '" [' . $conn->error . ']');
}
$conn -> close;
?>
我想我只是缺少对这些信标如何工作的一些基本金属理解。 validclick 应该将信息发送到此 URL,并将这些变量附加到 URL 的末尾。所以这在我访问测试 URL(例如:http://www.mywebsite.com/beacon_url/impression_beacon.php?id=1234&ts=2018-01-12%14:44:30&slotid=1234&q=1234&u=1234&ty=1234&nq=1234&nr=1234)时有效,但是当我们收到印象时似乎没有将数据插入我们的 table。
编辑:我认为我的问题是我的 php 与我的形象不符。我认为页面只能包含图像。但是,如果我将它从页面中删除,我不知道如何从信标接收数据。
希望此 php 代码能帮助任何人在将来尝试设置印象信标。此代码适用于 Inuvo。
/*
* YPA Impression BEACON END POINT
*/
// *** lowercase all param names ***
$_REQUEST = array_change_key_case($_REQUEST);
// Default impression args
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; // = coresponding impression ID
$ts = isset($_REQUEST['ts']) ? $_REQUEST['ts'] : null; // = unix timestamp of impression
$slotid = isset($_REQUEST['slotid']) ? $_REQUEST['slotid'] : null; // = location in page
$q = isset($_REQUEST['q']) ? $_REQUEST['q'] : null; // = keyword
$u = isset($_REQUEST['u']) ? $_REQUEST['u'] : null; // = landing page url
$ty = isset($_REQUEST['ty']) ? $_REQUEST['ty'] : null; // = affid
$nq = isset($_REQUEST['nq']) ? $_REQUEST['nq'] : null; // = number of ads requested for that ad unit / slot (New)
$nr = isset($_REQUEST['nr']) ? $_REQUEST['nr'] : null; // = number of ads returned for that ad unit / slot (New)
// Your custom args defined in your YPA code block
// serveBeacon:"x=1&y=2&z=3", //string of key value pairs you want to hit this end point.
$x = isset($_REQUEST['x']) ? $_REQUEST['x'] : null;
$y = isset($_REQUEST['y']) ? $_REQUEST['y'] : null;
$z = isset($_REQUEST['z']) ? $_REQUEST['z'] : null;
// write to your storage/db here
// Return image 1x1 gif content
header('Content-Type: image/gif');
echo base64_decode('R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==');