/**
  * Initializes the default client to use. Uses the socket consumer by default.
  * @param $token
  * @param $secret
  * @param array $options
  * @throws Exception
  */
 public static function init($token, $secret, $options = array())
 {
     self::assert($token, "Salesmachine::init() requires token");
     self::assert($secret, "Salesmachine::init() requires secret");
     $options['batch_size'] = 100;
     if (isset($options['use_buffer'])) {
         $options['batch_size'] = $options['use_buffer'] ? 100 : 1;
     }
     self::$client = new Salesmachine_Client($token, $secret, $options);
 }
 function testPageview()
 {
     $this->assertTrue(Salesmachine::track_pageview("75478", array("account_uid" => "78910", "display_name" => "Registration")));
 }
Beispiel #3
0
    }
    $payload = json_decode($line, true);
    //$dt = new DateTime($payload["timestamp"]);
    //$ts = floatval($dt->getTimestamp() . "." . $dt->format("u"));
    //$payload["timestamp"] = $ts;
    //$type = $payload["type"];
    $ret = call_user_func_array(array("Salesmachine", "set_contact"), array($payload));
    if ($ret) {
        $successful++;
    }
    $total++;
    if ($total % 100 === 0) {
        Salesmachine::flush();
    }
}
Salesmachine::flush();
unlink($file);
/**
 * Sent
 */
print "sent {$successful} from {$total} requests successfully";
exit(0);
/**
 * Parse arguments
 *
 * @param $argv
 * @return array
 */
function parse($argv)
{
    $ret = array();