This section includes the available interfaces with examples.
Methods
setDomain
/**
* @param string $domain Specifies the domain within which this cookie should be presented.
*/
public function setDomain($domain);getDomain
/**
* @return string Gets the domain name of this cookie.
*/
public function getDomain();setMaxAge
/**
* Sets the maximum age in seconds for this cookie.
*
* @param integer $expiry Sets the maximum age in seconds for this cookie.
*/
public function setMaxAge($expiry);getMaxAge
/**
* Gets the maximum age in seconds of this cookie.
*
* @return integer Gets the maximum age in seconds of this cookie.
*/
public function getMaxAge();The value is relative (e.g. 15552000 = 180 days for the everID cookie, -1 for a session cookie). For setcookie() use time() + $cookie->getMaxAge() as expiry, or 0 for a session cookie.
setPath
/**
* @param string $uri Specifies a path for the cookie to which the client should return the cookie.
*/
public function setPath($uri);getPath
/**
* @return string Returns the path on the server to which the browser returns this cookie.
*/
public function getPath();setSecure
/**
* @param bool $flag Indicates to the browser whether the cookie should only be sent using a secure protocol,
* such as HTTPS or SSL.
*/
public function setSecure($flag);isSecure
/**
* @return bool Returns true if the browser is sending cookies only over a secure protocol, or false if the browser
* can send cookies using any protocol.
*/
public function isSecure();getName
/**
* @return string Returns the name of the cookie.
*/
public function getName();getValue
/**
* @return string Gets the current value of this cookie.
*/
public function getValue();setHttpOnly
/**
* @param bool $isHttpOnly Marks or unmarks this cookie as HttpOnly.
*/
public function setHttpOnly($isHttpOnly);isHttpOnly
/**
* @return bool Checks whether this cookie has been marked as HttpOnly.
*/
public function isHttpOnly();Create your own LoggerClass to debug our Mapp Intelligence PHP library.
Methods
log
/**
* @param string ...$msg Debug message
*/
public function log(...$msg);Example
class CustomLogger implements MappIntelligenceLogger
{
/**
* @param mixed ...$msg Debug message
*/
public function log(...$msg)
{
error_log(...$msg);
}
}Create your own ConsumerClass to use for data transfer to Intelligence.
Methods
sendBatch
/**
* @param array $batchContent List of tracking requests
* @return bool
*/
public function sendBatch(array $batchContent);Example
class TestCustomPrintConsumer implements MappIntelligenceConsumer
{
/**
* @param array $batchContent List of tracking requests
* @return bool
*/
public function sendBatch(array $batchContent) {
for ($i = 0; $i < count($batchContent); $i++) {
echo $batchContent[$i] . "\n";
}
return true;
}
}Optional extension of MappIntelligenceConsumer: a consumer implementing it can tell the queue that a batch can never be sent, instead of only "sent" or "retry". Consumers that only implement MappIntelligenceConsumer keep working: true counts as SENT, false as RETRY.
Methods
send
/**
* @param array $batchContent List of tracking requests
* @return string MappIntelligenceBatchResult::SENT, ::RETRY or ::DISCARDED
*/
public function send(array $batchContent);Result | Meaning |
|---|---|
MappIntelligenceBatchResult::SENT | The batch was delivered. |
MappIntelligenceBatchResult::RETRY | The batch could not be delivered right now, it goes back into the queue and is retried. |
MappIntelligenceBatchResult::DISCARDED | The batch can never be sent (permanent client error, oversized payload). It leaves the queue, but was not delivered either; the flush reports a failure. |
An invalid result or an exception counts as RETRY.
Example
class TestCustomResultConsumer implements MappIntelligenceBatchResultConsumer
{
public function send(array $batchContent) {
// HTTP status, 0 if there was no response (no connection, timeout)
$status = my_send($batchContent);
if ($status > 0 && $status < 400) {
return MappIntelligenceBatchResult::SENT;
}
if ($status >= 400 && $status < 500 && $status !== 408 && $status !== 429) {
return MappIntelligenceBatchResult::DISCARDED;
}
// no response, 408, 429 and 5xx: try again later
return MappIntelligenceBatchResult::RETRY;
}
public function sendBatch(array $batchContent) {
return $this->send($batchContent) === MappIntelligenceBatchResult::SENT;
}
}