Send Ex added
This commit is contained in:
@@ -4,8 +4,41 @@
|
|||||||
{ "type": "ValidationTextBox", "name": "WbToken", "caption": "Token" },
|
{ "type": "ValidationTextBox", "name": "WbToken", "caption": "Token" },
|
||||||
{ "type": "ValidationTextBox", "name": "WbAppId", "caption": "App ID"},
|
{ "type": "ValidationTextBox", "name": "WbAppId", "caption": "App ID"},
|
||||||
{ "type": "ValidationTextBox", "name": "WbTemplate", "caption": "Templatename"},
|
{ "type": "ValidationTextBox", "name": "WbTemplate", "caption": "Templatename"},
|
||||||
{ "type": "ValidationTextBox", "name": "WbLang", "caption": "Language Code (de NICHT de_DE)"}
|
{ "type": "ValidationTextBox", "name": "WbLang", "caption": "Language Code (de NICHT de_DE)"},
|
||||||
|
{
|
||||||
|
"type": "List",
|
||||||
|
"name": "Numberlist",
|
||||||
|
"caption": "Reciever List",
|
||||||
|
"rowCount": 5,
|
||||||
|
"add": true,
|
||||||
|
"delete": true,
|
||||||
|
"sort": {
|
||||||
|
"column": "Name",
|
||||||
|
"direction": "ascending"
|
||||||
|
},
|
||||||
|
"columns": [{
|
||||||
|
"caption": "Name",
|
||||||
|
"name": "Name",
|
||||||
|
"width": "auto",
|
||||||
|
"add": "",
|
||||||
|
"edit": {
|
||||||
|
"type": "ValidationTextBox"
|
||||||
|
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"caption": "Whatsappnumber",
|
||||||
|
"name": "Number",
|
||||||
|
"width": "75px",
|
||||||
|
"add": 20.0,
|
||||||
|
"edit": {
|
||||||
|
"type": "ValidationTextBox"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
"values": [{
|
||||||
|
"Name": "Hans Maier Müller der Echte",
|
||||||
|
"Number": "49150815123456"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
"actions":
|
"actions":
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class WhatsappMessage extends IPSModule {
|
|||||||
$this->RegisterPropertyString("WbAppId","");
|
$this->RegisterPropertyString("WbAppId","");
|
||||||
$this->RegisterPropertyString("WbTemplate","stoerung");
|
$this->RegisterPropertyString("WbTemplate","stoerung");
|
||||||
$this->RegisterPropertyString("WbLang","de");
|
$this->RegisterPropertyString("WbLang","de");
|
||||||
$this->RegisterPropertyString("Parameterlist","");
|
$this->RegisterPropertyString("Numberlist","");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Überschreibt die intere IPS_ApplyChanges($id) Funktion
|
// Überschreibt die intere IPS_ApplyChanges($id) Funktion
|
||||||
@@ -41,8 +41,8 @@ class WhatsappMessage extends IPSModule {
|
|||||||
|
|
||||||
return $number;
|
return $number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SendMessage(string $recip, array $paramvals) {
|
public function SendMessageEx(string $recip, array $paramvals) {
|
||||||
|
|
||||||
$token = $this->ReadPropertyString("WbToken");
|
$token = $this->ReadPropertyString("WbToken");
|
||||||
$appId = $this->ReadPropertyString("WbAppId");
|
$appId = $this->ReadPropertyString("WbAppId");
|
||||||
@@ -84,7 +84,7 @@ class WhatsappMessage extends IPSModule {
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
echo "JSON:\n" . json_encode($data, JSON_PRETTY_PRINT) . "\n\n";
|
//echo "JSON:\n" . json_encode($data, JSON_PRETTY_PRINT) . "\n\n";
|
||||||
|
|
||||||
$ch = curl_init('https://graph.facebook.com/v22.0/'.$appId.'/messages');
|
$ch = curl_init('https://graph.facebook.com/v22.0/'.$appId.'/messages');
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
@@ -98,9 +98,31 @@ class WhatsappMessage extends IPSModule {
|
|||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
return isMessageAccepted($response);
|
||||||
// echo "HTTP-Code: $httpcode\nAntwort: $response\n";
|
// echo "HTTP-Code: $httpcode\nAntwort: $response\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private function SendMessage(array $paramvals) {
|
||||||
|
|
||||||
|
$arrnumbers = $this->ReadPropertyString("Numberlist");
|
||||||
|
$entries = json_decode($arrnumbers, true);
|
||||||
|
|
||||||
|
foreach ($entries as $entry){
|
||||||
|
$number = $entry['Number'];
|
||||||
|
SendMessageEx($number[], $paramvals);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private function isMessageAccepted($jsonResponse) {
|
||||||
|
$data = json_decode($jsonResponse, true);
|
||||||
|
|
||||||
|
// message_status MUSS vorhanden und accepted sein
|
||||||
|
if (isset($data['messages'][0]['message_status']) && $data['messages'][0]['message_status'] === 'accepted') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wenn message_status fehlt oder nicht "accepted" ist → false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
"version": "6.0",
|
"version": "6.0",
|
||||||
"date": 1491343200
|
"date": 1491343200
|
||||||
},
|
},
|
||||||
"version": "1.0",
|
"version": "1.1",
|
||||||
"build": 5,
|
"build": 5,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user