Code: Select all
<?php
phpinfo();
?>
Moderator: leecollings
Code: Select all
<?php
phpinfo();
?>
seems something is wrong with your .php file, you might want to check the source vice php checker??ropske wrote:will it also work with:
PHP Version
5.5.22
?
i have this one installed in my nas and if i want to run the telegram.php
i'm getting this error:
HTTP 500-fout
Dat is vreemd... deze pagina kan niet worden weergegeven door de website
Code: Select all
#!/usr/bin/php
<?php error_reporting(E_ALL);ini_set("display_errors","on");
$silent=true;$type=NULL;$to=NULL;
if(isset($_REQUEST['silent']))$silent=$_REQUEST['silent'];
if(isset($_REQUEST['text'])){$type='text';$content=$_REQUEST['text'];}
if(isset($_REQUEST['photo'])){$type='photo';$content=$_REQUEST['photo'];}
if(isset($_REQUEST['video'])){$type='video';$content=$_REQUEST['video'];$silent=true;}
if(isset($_REQUEST['to']))$to=$_REQUEST['to'];
if($to=='Wife')$telegramchatid=12345678;
elseif($to=='channel')$telegramchatid=-1234567890123;
else $telegramchatid=87654321;
if(!empty($argv[1])&&!empty($argv[2])){$type=$argv[1];$content=$argv[2];}
if(!empty($argv[1])&&$argv[1]=="snapshot") {$type='photo';$content = "/run/pikrellcam/mjpeg.jpg";$silent=true;}
if(isset($type)&&isset($content)){
$bot_url="https://api.telegram.org/bot123592115:A2EZ-xCRhO-RBf2qICiJs8q2A_2YIr1irxI/";
if($type=="text"){$url=$bot_url."sendMessage?chat_id=".$telegramchatid;$post_fields=array('chat_id'=>$telegramchatid,'text'=>$content,'disable_notification'=>$silent);}
elseif($type=="photo"){$url=$bot_url."sendPhoto?chat_id=".$telegramchatid;$post_fields=array('chat_id'=>$telegramchatid,'photo'=>new CURLFile(realpath($content)),'disable_notification'=>true);}
elseif($type=="video"){$url=$bot_url."sendVideo?chat_id=".$telegramchatid;$post_fields=array('chat_id'=>$telegramchatid,'video'=>new CURLFile(realpath($content)),'disable_notification'=>true);}
$ch=curl_init();curl_setopt($ch,CURLOPT_HTTPHEADER,array("Content-Type:multipart/form-data"));curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);
for($x=1;$x<=100;$x++){
$result=json_decode(curl_exec($ch),true);
if($result['ok']===true)break;
sleep($x*3);
}
}
A well I had to modify that code a bit as well to have it work without any problems on my setup. This is my telegram.php. Credits ofcourse go to the original writerropske wrote:i just copied the code from you:
but when i enter this in http://phpcodechecker.com/ i'm getting indeed some errors.
PHP Syntax Check: Parse error: syntax error, unexpected '$telegramchatid' (T_VARIABLE) in your code on line 10
else $telegramchatid=123456789;
PHP Syntax Check: Errors parsing your code
when i change to this:
else ($telegramchatid=123456789);
it's ok, but then the next error comes...
Code: Select all
#!/usr/bin/php
<?php
error_reporting(E_ALL);ini_set("display_errors", "on");
$silent=false;$type='';
if(isset($_REQUEST['silent'])) $silent = $_REQUEST['silent'];
if(isset($_REQUEST['text'])) {$type='text';$content = $_REQUEST['text'];}
if(isset($_REQUEST['photo'])) {$type='photo';$content = $_REQUEST['photo'];}
if(isset($_REQUEST['video'])) {$type='video';$content = $_REQUEST['video'];$silent=true;}
if(!empty($argv[1])&&!empty($argv[2])) {$type=$argv[1];$content = $argv[2];}
//if(!empty($argv[1])&&$argv[1]=="snapshot") {$type='photo';$content = "/var/tmp/snapshot1.jpg";$silent=true;}
echo '<pre>REQUEST=';print_r($_REQUEST);echo '</pre>';
if(isset($type)&&isset($content)) {
echo 'Type = '.$type.'<br/>Content = '.$content.'<br/>';
$telegrambot='123456789:AA_______________________________poQ';
$telegramchatid=-1111222233334;
$bot_url = "https://api.telegram.org/bot$telegrambot/";
if($type=="text") {
$url = $bot_url . "sendMessage?chat_id=" . $telegramchatid ;
$post_fields = array('chat_id' => $telegramchatid,
'text' => $content,
'disable_notification' => $silent
);
}
else if($type=="photo") {
$url = $bot_url . "sendPhoto?chat_id=" . $telegramchatid ;
$post_fields = array('chat_id' => $telegramchatid,
'photo' => new CURLFile(realpath($content)),
'disable_notification' => true
);
}
else if($type=="video") {
$url = $bot_url . "sendVideo?chat_id=" . $telegramchatid ;
$post_fields = array('chat_id' => $telegramchatid,
'video' => new CURLFile(realpath($content)),
'disable_notification' => true
);
}
//echo 'URL = '.$url.'<br/>';
//echo '<pre>post_fields=';print_r($post_fields);echo '</pre>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type:multipart/form-data"
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
$output = json_decode(curl_exec($ch),true);
//echo '<pre>Output=';print_r($output);echo '</pre>';
}
Code: Select all
//if(!empty($argv[1])&&$argv[1]=="snapshot") {$type='photo';$content = "/var/tmp/snapshot1.jpg";$silent=true;}
assuming you configured your webserver correctly (mine is running on default port 80 not 5000) the command would be:ropske wrote:because it's still not working
Code: Select all
http://192.168.2.10/php/telegram.php?text=Reboot_MQX
I don't use synology for this.ropske wrote:i cannot change my port
i have a zyxell nas 540
maybe it is something at my nas-server i need to setup.
i better bought a synology it seems
Users browsing this forum: No registered users and 1 guest