androi...@gmail.com writes:
> Il giorno mercoledě 1 febbraio 2017 19:10:46 UTC+1, Jerry Stuckle ha scritto:
>> On 2/1/2017 11:09 AM,
androi...@gmail.com wrote:
<snip>
>> > The content of the php script is the following:
>> >
>> > <?php
>> > $telegrambot='276929052:AAEdjgS4w3Jf8zuWl3uLhvs-mycode';
>> > $telegramchatid=174428000;
>> >
>> > function sendtelegram($msg)
>> > {
>> > global $telegrambot,$telegramchatid;
>> > $msg= "Messaggio dal CRM.";
>> > $url='
https://api.telegram.org/bot'.$telegrambot.'/sendMessage';$data=array('chat_id'=>$telegramchatid,'text'=>$msg);
>> > $options=array('http'=>array('method'=>'POST','header'=>"Content-Type:application/x-www-form-urlencoded\r\n",'content'=>http_build_query($data),),);
>> > $context=stream_context_create($options);
>> > $result=file_get_contents($url,false,$context);
>> > return $result;
>> > }
>> > //obbligatorio questo sotto per richiamare la funzione in modo
>> > tale che messaggio venga inviato
>> > sendtelegram ("Ciao");
>> > //Example:
>> > //telegram('This is a test message sent to Telegram bot at'.time());
>> > ?>
<snip>
> If i launch the script from the browser
This phrase suggests a misunderstanding. PHP runs on webservers, not in
browsers. Presumably what you mean here is that you request a resource
(the browser doing it's usual thing) and the server executes the script
to generate the document the browser receives. Again, that the usual
process -- PHP code runs on the server in response to client request for
those resources that need PHP processing.
If this is not what you mean by "i launch the script from the browser"
I, for one, need to know more. One way is to describe exactly the
actions you take, step by step.
> the message gets sent on
> telegram, if i try to call the script from php so that it runs as if i
> called it manually from my browser, it won't send the telegram message
> and it does not disply any errors.
Similarly, I not sure what calling he script from PHP means. Can you
say exactly what you do, step by step?
<snip>
--
Ben.