my name is kevin, iam the developer of https://www.pushsafer.com.
Is there a way to get help for improving the pushsafer notification plugin.
Unfortunately, I do not have the necessary knowledge to do this myself.
With pushsafer you can also send images in a push-notification. So my idea is to add a new html input field (absolute Image URL) to the setup page, see image. This is intended to provide the user with the possibility to display images of e.g. IP cameras or door bells directly by push notification.
This URL should be accessible locally or also from the Internet.
When domoticz call the pushsafer plugin, the image from url should be loaded and converted to an base64 encoded string. This string must transfered as the param p to the pushsafer API
I only have an php example:
Code: Select all
$image = file_get_contents('http://user:[email protected]/snapshot.cgi');
$imgtype ='jpg';
$image = 'data:image/'.$imgtype.';base64,'.base64_encode($image);
Code: Select all
#include "stdafx.h"
#include "NotificationPushsafer.h"
#include "../httpclient/HTTPClient.h"
#include "../main/Logger.h"
#include "../httpclient/UrlEncode.h"
CNotificationPushsafer::CNotificationPushsafer() : CNotificationBase(std::string("pushsafer"), OPTIONS_URL_SUBJECT | OPTIONS_URL_BODY | OPTIONS_URL_PARAMS)
{
SetupConfig(std::string("PushsaferEnabled"), &m_IsEnabled);
SetupConfig(std::string("PushsaferAPI"), _apikey);
}
CNotificationPushsafer::~CNotificationPushsafer()
{
}
bool CNotificationPushsafer::SendMessageImplementation(
const uint64_t Idx,
const std::string &Name,
const std::string &Subject,
const std::string &Text,
const std::string &ExtraData,
const int Priority,
const std::string &Sound,
const bool bFromNotification)
{
//send message to Pushsafer
std::string cSubject = (Subject == Text) ? "Domoticz" : Subject;
bool bRet;
std::string sResult;
std::stringstream sPostData;
std::vector<std::string> ExtraHeaders;
// Code for downloading the image from URL and encoding to a base64 string
sPostData << "k=" << _apikey << "&t=" << cSubject << "&m=" << Text << "&p=" << image1 << "&p2=" << image2 << "&p3=" << image3;
//Add the required Access Token and Content Type
ExtraHeaders.push_back("Content-Type: application/x-www-form-urlencoded");
bRet = HTTPClient::POST("https://www.pushsafer.com/api",sPostData.str(),ExtraHeaders,sResult);
bool bSuccess = (sResult.find("\"success\":") != std::string::npos);
if (!bSuccess)
_log.Log(LOG_ERROR, "Pushsafer: %s", sResult.c_str());
return (bRet && bSuccess);
}
bool CNotificationPushsafer::IsConfigured()
{
return _apikey != "";
}
Kevin