Exemple #1
0
 function Run()
 {
     $key = $this->GetParam('key', 'str');
     $title = $this->GetParam('title', 'str');
     $message = $this->GetParam('message', 'int');
     $priority = $this->GetParam('priority', 'str');
     $url = $this->GetParam('url', 'str');
     $custom = $this->GetParam('custom', 'raw');
     $message = str_replace('{custom}', $custom, $message);
     if (!strlen($priority)) {
         $priority == 0;
     }
     $result = '';
     if ($key and $title and $message) {
         require_once dirname(__FILE__) . '/class.php-prowl.php';
         $prowl = new Prowl();
         $prowl->setApiKey($key);
         //$prowl->setDebug(true);
         $result = $prowl->add($this->conf['app']['name'], $title, $priority, $message, $url);
         if ($result->success['code'] == 200) {
             $this->DisplayJson(true, array('code' => 200, 'message' => "Successfully Sent Notification : {$title}", 'api_result' => $result));
         } else {
             $this->DisplayJson(false, array('code' => 500, 'message' => "Failed to send Notification : {$title}", 'api_result' => $result));
         }
     } else {
         $this->DisplayJson(false, array('code' => 500, 'message' => "Missing some parameters!"));
     }
 }
    // Type of cache
    $location = $matches[4];
    // Location of this cache
    $distance = $matches[5];
    // Distance from your home co-ordinates
    $date = $matches[6];
    // Date this log was created
    $log = trim($matches[7]);
    // The log message
    $username = $matches[9];
    // Username of the Geocaching.com User
    $link_log = $matches[8];
    // ID for Link to the log message
    $link_user = $matches[10];
    // ID for Link to user profile
    // Strip through the subject to get the 'action' of this message, such as found,
    // did not find, archived, published etc
    $subject = str_replace("[GEO] Notify: ", "", $structure->headers["subject"]);
    $action = str_replace($title, "", $subject);
    $action = str_replace("(" . $type . ")", "", $action);
    $action = trim(str_replace($username, "", $action));
    // Send a notification out via Prowl
    $prowl = new Prowl();
    $prowl->setApiKey("3d6d41d6a5fb532a51ed40b3fR45tdeb97b6e86d");
    $application = "Geocaching.com";
    $event = "{$username} {$action} {$title} ({$id})";
    $text = $log;
    $url = "http://coord.info/" . $link_log;
    $priority = 0;
    $message = $prowl->push($application, $event, $text, $url, $priority);
}