Skip to content

Commit

Permalink
Create source-Send_to_Pushover.module
Browse files Browse the repository at this point in the history
  • Loading branch information
drmessano authored Jun 29, 2016
1 parent 7468136 commit 92b7a58
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions sources/source-Send_to_Pushover.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****
* Developer Notes:
*
*
*
*
* Version history:
* 2016-06-29 first version for 13 by drmessano
*
**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****/

class Send_to_Pushover extends superfecta_base {

public $description = "Sends Caller ID Name and Number as a Pushover notice";
public $version_requirement = "2.11";
public $source_param = array(
'User_or_Group_Key' => array(
'description' => 'Enter User or Group API Key available from https://pushover.net',
'type' => 'text',
'default' => null
),
'App_Token' => array(
'description' => 'Enter App API Token/Key available from https://pushover.net/apps',
'type' => 'text',
'default' => null
),
'Device' => array(
'description' => '(Optional) Enter Device(s) available from https://pushover.net',
'type' => 'text',
'default' => null
),
'Priority' => array(
'description' => 'Set Message Priority. See: https://pushover.net/api#priority',
'type' => 'select',
'option' => array(
'-2' => 'Lowest (-2)',
'-1' => 'Low (-1)',
'0' => 'Normal (0)',
'1' => 'High (1)',
'2' => 'Emergency (2)',
),
'default' => '0'
),
'Title' => array(
'description' => 'Set Message Title',
'type' => 'text',
'default' => 'Incoming call'
),
);

function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) {
$this->DebugPrint("Pushing notice to Pushover");
$curl = curl_init();
$url = 'https://api.pushover.net/1/messages.json';
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
$queryData['user'] = $run_param['User_or_Group_Key'];
$queryData['token'] = $run_param['App_Token'];
$queryData['device'] = $run_param['Device'];
$queryData['priority'] = $run_param['Priority'];
$queryData['title'] = $run_param['Title'];
$queryData['message'] = "Incoming call from: ".$first_caller_id."\r"."From phone number: ".$thenumber;
curl_setopt($curl, CURLOPT_POSTFIELDS, $queryData);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, TRUE);
$response = curl_exec($curl);
curl_close($curl);
}
}

0 comments on commit 92b7a58

Please sign in to comment.