예제 #1
0
 public function send(Event_Container $events)
 {
     $result = false;
     $path = $this->createSubPath($this->path, $events->getApiKey(), time());
     $fp = fopen($path . uniqid(mt_rand()), 'a');
     if ($fp) {
         flock($fp, LOCK_EX);
         $result = fputs($fp, json_encode(array('api_key' => $events->getApiKey(), 'data' => $events->getData())));
         fflush($fp);
         flock($fp, LOCK_UN);
         fclose($fp);
     }
     return $result !== false;
 }
예제 #2
0
 public function send(Event_Container $events)
 {
     $apiKey = $events->getApiKey();
     $data = $events->getData();
     $data = json_encode($data);
     $signature = hash_hmac('sha512', $data, $events->getSecretKey());
     $requestSuccessful = false;
     $try = 0;
     do {
         $try++;
         $response = $this->sendReal($data, $apiKey, $signature);
         if ($response) {
             $response = json_decode($response);
             if ($response && isset($response->status) && $response->status === 'ok') {
                 $requestSuccessful = true;
             }
         }
     } while ($requestSuccessful !== true && $try <= $this->retryCount);
     return $requestSuccessful;
 }