├── README.markdown ├── config └── prowl.php ├── controllers └── prowl_test.php └── libraries └── Prowl.php /README.markdown: -------------------------------------------------------------------------------- 1 | CodeIgniter-Prowl 2 | ================= 3 | 4 | Send iPhone notifications from your CodeIgniter application with the Prowl library. 5 | Based on the PHP Prowl from Leon Bayliss and cleaned up. 6 | 7 | Updated Phil's library to work with the current version of Prowl's API. 8 | 9 | 10 | Requirements 11 | ------------ 12 | 13 | 1. An iPhone 14 | 2. The Prowl app from the App Store installed on your iPhone 15 | 3. A [Prowl account](http://www.prowlapp.com/) 16 | 17 | 18 | Usage 19 | ----- 20 | 21 | 1. Update the settings in the config file (config/prowl.php) 22 | 2. Do something like this: 23 | 24 | $this->load->library('prowl'); 25 | 26 | $result = $this->prowl->send('Reminder', 'Be an idiot in public.'); 27 | 28 | print_r($result); 29 | 30 | 3. There is no #3! Simple as that! 31 | 32 | Credits 33 | ------- 34 | 35 | Based on **Leon Bayliss**' PHP Prowl 36 | 37 | Original CodeIgniter class by **Phil Sturgeon** 38 | 39 | Updated to latest API version by **Erik Brännström** -------------------------------------------------------------------------------- /config/prowl.php: -------------------------------------------------------------------------------- 1 | load->library('prowl', $config); 14 | 15 | $result = $this->prowl->send('Reminder', 'Be an idiot in public.'); 16 | 17 | print_r($result); 18 | } 19 | } 20 | 21 | ?> -------------------------------------------------------------------------------- /libraries/Prowl.php: -------------------------------------------------------------------------------- 1 | 0) 18 | { 19 | $this->initialize($config); 20 | } 21 | } 22 | 23 | // -------------------------------------------------------------------- 24 | 25 | /** 26 | * Initialize preferences 27 | * 28 | * @param array 29 | * @return void 30 | */ 31 | public function initialize($config = array()) 32 | { 33 | foreach ($config as $key => $val) 34 | { 35 | if (isset($this->$key)) 36 | { 37 | $this->$key = $val; 38 | } 39 | } 40 | } 41 | 42 | /** 43 | * Send a push notification. Returns the XML response from the server as a string. 44 | * 45 | * @param $event string 46 | * @param $description string 47 | * @param $priority integer 48 | * @return string 49 | */ 50 | public function send($event, $description, $priority = 0) 51 | { 52 | $url = $this->url . 'add'; 53 | $fields = array( 54 | 'apikey' => $this->apikey, 55 | 'priority' => $priority, 56 | 'application' => $this->application, 57 | 'event' => $event, 58 | 'description' => $description 59 | ); 60 | 61 | $ch = curl_init($url); 62 | 63 | curl_setopt($ch, CURLOPT_POST, true); 64 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields)); 65 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 66 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 67 | 68 | $return = curl_exec($ch); 69 | curl_close($ch); 70 | 71 | return $return; 72 | } 73 | 74 | }; 75 | 76 | // EOF: application/libraries/Prowl.php 77 | --------------------------------------------------------------------------------