PHP app the retrieves constantly changing or new data - php

How would one develop a PHP app that would constantly update the current state of a webpage? Is there some sort of a pattern that can be implemented to achieve this? What would be the ajax programming needed to update the state of what a web page shows?
The basic idea is that of the Facebook news feed where the page is constantly changing as new data gets entered or data is modified.

Why don't you just make API call.
or
Have a look at their documentation: https://developers.facebook.com/docs/php/gettingstarted/

Related

What is the best way to achive realtime info on my website currently using php yii framework and django-rest for api with mysql

Here i have no idea, what to exactly use to get the real-time information on the web page on my already developed application. The real-time feature will be based on online Auction feature, as a bidder bids low/high amount all the concerned user should reflect the newer price on their window immediately without refreshing the web page.
Please suggest me the best way possible, my application based on:
PHP 5 frontend with yii 1.1.15 framework
Python django-rest framework for the rest api to fetch data from mysql database.
for this i have heard about the node js, but will it be possible using only node js without using mongodb/rethinkdb angular or express js or socket.io.
Why do you need bout Yii and Python? DRF is very easy to use and will provide the backend to provide a rest API and the front end can be something as simple as HTML/CSS/js to fetch data from the REST API. Yii will not add any value to this system.
You need to read up on how an API based system works works (which is what you are trying to do.

How do I pass php form data to an angular2 app?

I'm still quite new to angular2/4 so forgive me if I'm missing something obvious.
I am trying to update a booking process and we are doing this with angular2/4. Currently the booking process starts on a php website, once some basic information is filled out the angular app is supposed to take over. What I'm not sure of is how I'm supposed to take the form data from PHP and receive that data in my angular app.
There is an express.js back end for the angular app, but I don't understand how I would be able to post from the PHP site and return the result to the angular app.
Again sorry, I'm still new to angular so I'm not sure how I should approach this.
Create an API (http://localhost:8080/bookings/) in your existing PHP application which your angular app can access via a GET/POST request using angulars HTTP client. https://angular.io/guide/http.
Or
Alternatively, use the express backend to talk to the MySql DB / Or other DB that your php application is using. Use express as an API similar to the above or simply render the page with the data obtained from the DB. https://expressjs.com/en/guide/database-integration.html

How to fetch data from external site to own site

I want to fetch data from live stock market to my web site. By using php and jQuery.
Has the source got an API you can work with to fetch the data? If so read their docs and implement it.
If not you could possibly do a Curl request and parse the data you need if your allowed.
More importantly you need to be more specific with your question if you want to get good answers, if any at all :-).
You need to find a web service that offers a stock market feed in the form of JSON or XML, so that your computer would be able to parse it. Not a website. Most of those feeds are paid - especially those that are close to real-time.
Then, once you have such a feed, you should be able to access it via your browser - just by typing in the URL. For example, http://www.quotewebsite.com/symbol=MSFT
This will help you understand what your server side script is supposed to do. Then, in your PHP script (PHP is a server-side programming language), issue a CURL request to download that specific page into your website's database (ex. MySQL). This will allow you to have historical data inside your own system. Then you get to render that data back to your own customers by querying your own database.

FaceBook php api get realtime updates?

Hi i am trying to use Realtime updates in facebook application,
My application basically backs up the user's photos, messages and friendlist, i want when a user adds a new friend data on server should also be updated, when a user adds a new album the most recent album should be downloaded automatically to my server
I got this code from github-php , but dont know what next?
Please help if anyone has done with real time updates
you need to query the code after certain interval which you can use AJAX to update the page without refresh.
There is no automatic updates without query the information every time.
You have to subscribe using one module and you specify a callback url during the subscription... you only subscribe once and you get updates for everyone who has authorized your app. The updates come to you via the callback url and its very crappy info that basically tells you that you have to go back and query fb to get the full details.

php chat client

i need to create a chat application in php+js+ajax which need to be integrated to a site, where am stuck is to create a chat window , that need to be constant while going through different pages in the site . if any one can suggest a better way i will be grateful, thanks in advance
As for the actual chat application...
Using some kind of technology to push data from the server -> your users is the best way to achieve a real-time chat application.
I would highly recommend checking out APE (Ajax Push Engine).
It takes care of the server-side stuff and allows you to seamlessly transfer data from the server -> client.
As far as the chat window staying when you change pages, I can think of three options:
Put the chat in a separate frame and only change the main frame when going to a new page.
Change the page content with AJAX instead of making a full page reload.
Assuming the chat messages are being stored on the server, simply repopulate the chat with the most recent messages after the new page loads.
There are plenty of tutorials available, try one of these three that came up first from a Google search for "php chat tutorial":
http://www.tutorialized.com/tutorials/PHP/Chat-Systems/1
http://code.jenseng.com/jenChat/
http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=9

Categories