Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17328
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: PHP Script working fine from browser but not working when executed from php |
| Date | 2017-02-02 14:11 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <871svgn0mz.fsf@bsb.me.uk> (permalink) |
| References | <b82c3dc5-9c07-4e8f-8e31-ae82b9960eb8@googlegroups.com> <o6t87o$hr$1@jstuckle.eternal-september.org> <0bbb5cc1-bc35-4351-a8c4-b46ac7213099@googlegroups.com> |
androidmaroso@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, androidmaroso@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.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PHP Script working fine from browser but not working when executed from php androidmaroso@gmail.com - 2017-02-01 08:09 -0800
Re: PHP Script working fine from browser but not working when executed from php Jerry Stuckle <jstucklex@attglobal.net> - 2017-02-01 13:10 -0500
Re: PHP Script working fine from browser but not working when executed from php androidmaroso@gmail.com - 2017-02-02 01:16 -0800
Re: PHP Script working fine from browser but not working whenexecuted from php "R.Wieser" <address@not.available> - 2017-02-02 11:22 +0100
Re: PHP Script working fine from browser but not working when executed from php Tim Streater <timstreater@greenbee.net> - 2017-02-02 13:55 +0000
Re: PHP Script working fine from browser but not working when executed from php Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-02 14:11 +0000
Re: PHP Script working fine from browser but not working when executed from php Jerry Stuckle <jstucklex@attglobal.net> - 2017-02-02 11:19 -0500
csiph-web