From e505e2d089ef12f190b546133ffe59fa45e69300 Mon Sep 17 00:00:00 2001 From: Danny Messano Date: Wed, 29 Jun 2016 18:39:16 -0400 Subject: [PATCH] Create source-Send_to_Yo.module --- sources/source-Send_to_Yo.module | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 sources/source-Send_to_Yo.module diff --git a/sources/source-Send_to_Yo.module b/sources/source-Send_to_Yo.module new file mode 100644 index 00000000..7d1df46d --- /dev/null +++ b/sources/source-Send_to_Yo.module @@ -0,0 +1,53 @@ + array( + 'description' => 'Enter User or App API Key https://dashboard.justyo.co', + 'type' => 'text', + 'default' => null + ), + 'User' => array( + 'description' => 'Enter a specific Username or \'all\' to Yo all subscribers', + 'type' => 'text', + 'default' => 'all' + ), + ); + + function post_processing($cache_found, $winning_source, $first_caller_id, $run_param, $thenumber) { + $this->DebugPrint("Sending Yo"); + $curl = curl_init(); + $user = strtolower($run_param['User']); + if ($user == 'all') { + $url = 'https://api.justyo.co/yoall/'; + } else { + $url = 'https://api.justyo.co/yo/'; + } + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); + $queryData['api_token'] = $run_param['API_Token']; + if ($user != 'all') { + $queryData['username'] = $run_param['User']; + } + $queryData['text'] = "Call from: ".$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); + } +}