I need to configure TWILIO SMS account to forward the received SMS to some PHP URL. So,
now if I have that PHP URL already opened in my web browser, and if some message is being forwarded to this URL from TWILIO with GET request, how can I show the received data in that already opened PHP Web URL?
Ex : If I give this URL http://www.somephp.com/index.php in TWILIO dashboard to forward the incoming SMS with GET request.
And I open that in my web browser already to see if there is any SMS from TWILIO. How can I constantly check if any new SMS forwarded from TWILIO?
Can I use any TIMER to check GET requests ? Or Am I totally in wrong way? I cannot find any solution around when I google. Please forgive me if it seems to be a silly question. I would be very grateful if you could guide me in this issue. Thanks a lot for your time!
For easy you can use the jQuery library, then poll regularly for new data using a backend php script.
You'd have to use some JavaScript (jQuery might be easier) to run a setInterval function every X seconds. Anther option is you could use a meta-refresh that would simply reload the page every X seconds.
I dont think that way its possible to achieve what you want.
What you can do is -
set http://www.somephp.com/index.php as sms reply in you dashboard.
In index.php save any new request into a database with sender details and message content and time it was received.
Now write a new script say http://www.somephp.com/updateMessages.php
In this page use jquery or javascript to make AJAX request to a script which will connect to database and check if there are any new messages. If there is, display that message and start checking for a message received after this message.
This way if you will open http://www.somephp.com/updateMessages.php you will get all new messages here.
Related
I'd like to ask if anyone knows any way to redirect an user if a return has already been send.
In my case I try to accomplish the following. A pdf is generated and send by the browser as a download. But after it's being send I'd still like to redirect because the database records will be updated in the process.
my code in the controller is as below:
session::flash('informationmessage', 'The labour entries were billed');
return $pdf->download();
redirect('admin/customers');
any help would be appreciated, cheers
No, you can't. For the redirection is done by client side, it's a small js code generate by server side. When the request is done, the connection is closed. Server side can not send info to browser any more.
you may try open a new tab for download and you redirect the main tab.
In short, not possible. As you say, you have already returned a response before you get to your redirect. There
use jquery filedownloader for downloading the file, as it work on ajax request, you can do any further processing after download whether its a new response or new request ...
for more about http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/
We are making a app with php in which we want to push data to client browser same in the way in which facebook notificaiton sent by facebook. i know about commet and also have used ajax in past but ajax is not efficeint while commet programing is out of my mind.
Sample can seen at ESPNCRICINFO.COM live scorecard which is automatically pushed
by server to brwoser and than append to document without refreshing. Same app we
have to made.
Simply i need to build some code that send data to all the browser which have our webpage opened. No restrictions. Just need to send to all. So there is no need to check to whom data will be push.
I really need it urgently.
can you use JavaScript setTimeout(function name, seconds) ?
In JavaScript function you can generate .post request for some PHP script which can load messages, when the message will load, you can show it via you JavaScript. the timer will call this function for all people.
I want to receive the post request on a web page while my page isn't refreshing or is still or just open, sort of concept like dynamic messages without refreshing the page. I don't want to pull it using ajax
I tried sending request to that URL but that doesn't work. I wanted to know a way to receive a post data and display it to user.
Any help is appreciated.
I read about amazon sns push for http/s, but they too doesn't send request to each browser page. they just send the request to the server, how should i make things in a way that , that post request from amazon goes to every browser page wherever it is open and display the content in the post message.
Maybe you are looking for WebSocket? It is basically a protocol used to send information from server to client without the need for the client to make a request. Similar to what chats systems like facebook messenger use, it stops the client having to poll a server for data.
For my next application i would like to implement something that has a feature like the facebook wall but let me explain a bit. For those of you who used facebook you know that when somebody posts a message on your wall, and you are logged in to your account, you will get a notification immediately somewhere in the lower left corner. Lately they even pushed this a little bit further and if somebody comments on it the comments are updated as you visualize the page, it's like an instant chat.
My application will be developed in PHP, I will use Zend Framework to do it. I'm interested in the basic principle that makes the facebook wall behave like that (updates in real time). I know there is ajax involved but I can't really tell how is the javascript triggered when the user is doing something. Or even more, how to push back to a user some info that was added after he viewed the page. For example, let's say that a somebody adds me as a friend. I would like to see a notification saying "X has added you as a friend" if i am logged in. I hope you understand what I'm trying to do.
If you can tell me some basic ideas, maybe provide some links that have this information I would be very grateful.
Thank you for your time in reading this.
you need to look at comet , reverse ajax , ajax polling
If some event is triggered, then store the event on database (with ajax or without ajax).
You will be needing a script in server to check if some event has been triggered or not. This script should be able to check events that are stored in database.
You need to execute script in step 2 periodically. This can be acheived with with ajax (javascript or jquery) and a function settimeout (on javascript) to send ajax request to server periodically.
Changes are sent from server. So parse the response and update in page using javascipt and jquery.
So, it can be summarized as
Register an event (for one user)
Check the event (for other user)
Parse the response and update the page
There are several elegant ways to do this as answered by others.
The best would be the start the project and ask for help where ever stuck.
It is only partially possible to keep an HTTP connection open, so the best option is probably to poll for changes. You can send a request each second to see if anything is changed since time 'x'. On each response you send along the server time. With the new request you send the time of the old request and the server can return any events that happened inbetween.
Also you can read something about AMQP. You can send a message to recepients inboxes (after some actions in your system) and then read inboxes after start or with some time interval.
How a notification can be shown after we are receiving a new message like FACEBOOK is displaying without refreshing a page. ( facebook is showing RED color notification after receiving a new message).
Thank You
There are two ways out there, you poll, or Comet.
Polling means you ask this question to your server periodically: "is there a new message?" with Ajax. If there is a new message, server returns it or the number of new messages.
Or you can implement some kind of Comet. Comet is a technology which contains open connections between client and server. Since there is an open connection, your server can send new information to clients.
After the number of new messages arrived to you, you can edit your DOM via javascript to show a red notification whereever you want.
You need to use setInterval to periodically check for any new updates and then, if they are found, use ajax to pull in the message.
Easiest way is to use jquery to update the content of a div at a sepecific interval...
#idofdivtoupdate
as it says.. the id of the div you want to auto update...
setinterval is in miliseconds.. (so 5000 checks every 5 seconds)
function updatecontent(){
$('#idofdivtoupdate').load('yourserverscript.php');
}
setInterval("updatecontent()", 5000 );
If ive understood you correctly you need to look up a technology called AJAX, its a combination of JavaScript and XML which allows the sending and receiving of data behind the scenes ie without needed to refresh the page. Theres plenty of tutorials/information out there about it and its not difficult to get the hang of, hope this helps.