Pushover attach a image

Moderator: leecollings

Post Reply
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Pushover attach a image

Post by Minglarn »

Hi..
Trying to send a attachment with pushover without success..

Sending normal messages with topics works fine.
Does anyone have any ideas or a working script?

Using this example to send messages and it works well to send notifications to my Sony tv..
But how do I include a image in this php code?

Code: Select all

<?php
curl_setopt_array($ch = curl_init(), array(
  CURLOPT_URL => "https://api.pushover.net/1/messages.json",
  CURLOPT_POSTFIELDS => array(
    "token" => "APP_TOKEN",
    "user" => "USER_KEY",
    "message" => "hello world",
  ),
  CURLOPT_SAFE_UPLOAD => true,
  CURLOPT_RETURNTRANSFER => true,
));
curl_exec($ch);
curl_close($ch);
?>
As seen on Pushovers examples using curl is should be like this, but I have difficulties to implement this in PHP.
Code from https://updates.pushover.net/post/17004 ... ushover-30

Code: Select all

If you use curl to send notifications, it’s as easy as:

curl -s \
 --form-string "token=APP_TOKEN" \
 --form-string "user=USER_KEY" \
 --form-string "message=here is an image attachment" \
 -F "attachment=@/path/to/your/image.jpg" \
 https://api.pushover.net/1/messages.json


Skickat från min SM-N950F via Tapatalk
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
User avatar
Mediacj
Posts: 74
Joined: Wednesday 11 February 2015 16:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Pushover attach a image

Post by Mediacj »

I didn't succeed either in doing this directly in php but solved it this way:

In my php script I have this line:

Code: Select all

$output = exec("/home/pi/hw/watch/grpu.sh $zna");
The bash script I am calling grpu.sh is this:

Code: Select all

#!/bin/sh
curl -s \
 --form-string "token=TOKEN" \
 --form-string "user=USER" \
 --form-string "message=Er is $1 kWh opgewekt vandaag." \
 -F "attachment=@/home/pi/domoticz/www/zp.png" \
 https://api.pushover.net/1/messages.json
User avatar
Minglarn
Posts: 214
Joined: Friday 21 August 2015 19:27
Target OS: Raspberry Pi / ODroid
Domoticz version: v3.8153
Location: Stockholm / Sweden
Contact:

Re: Pushover attach a image

Post by Minglarn »

Thanks... but using curl is not an option at the moment.. . :(

I have the need to use the PHP script as a function so I can send messages and other stuff, like camera snapshots and etc.
When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest