Sync users data from PHP to meteor application - php

I have two applications, one in PHP and other in Meteor, My requirement is that when a user is created using PHP application, it should be also sync/add to the meteor application.
I have knowledge in meteor, but not in PHP, I am looking for creating a method in PHP, so that it can send a http or similar request with all user information to my meteor application(method), and here I can query for existing user or add a new one, is this approach possible or have some other way possible, if possible then please give me an idea how I can send request from the PHP side and get this request in meteor and accomplish my requirement.

Yes, it is possible. Create a function in PHP that would do a POST request using curl and it will send the data to and endpoint where your meteor application will take over. You can google how to send POST requests from PHP and the first link will give you an answer.
Just make an endpoint ready from your meteor app to receive the data from PHP app.

Related

How protect API request made from Flutter Web app?

I have an API developed in PHP for my Flutter web app. I am using this API to fetch all the data. But, I can see all the requests made to the server.
Is there any way to hide/restrict any unauthorized person to use my API? I am using HTTP library to make calls from my flutter app to API. I just want to hide those calls to web API. I have seen some websites do that. Since the server code and website code in those websites are in the same directory it can be accessed directly without having to make a request to the webserver.
Two problems I see are
You are able to see all the request made to backend server from your web page and you want to hide them.
The answer to this is No you cant. I say this based on my search in google and some posts in SO like this
You may think about disabling the developers tools. The answer is No and maybe with unknown side effects.
Is there any way to hide/restrict any unauthorized person to use my API?
The answer to this question is yes and can be done in many approaches. Like you said token based authorization has its own issue with keys being leaked and thats why there is always validity associated with it and should be considered. There are mechanisms such as refresh tokens to renew tokens etc.
The first and foremost thing I would do is enable CORS mechanism in your sever where the server will only allow request from very specific domains to be processed. More details available here

Laravel real time data update with mysql

How can I update a value to a view in laravel, whenever there is a change in mysql database. The update in the database can be from eloquent, external apps using api, or directly from phpmyadmin.
I don't want to use firebase.
You need to use websockets in order to do so.
Let's make a quick reminder of how a simple web app work:
The user uses a browser to make a request to your server
You server responds with a single response.
If the user wants other information, he needs to make a new request to your server.
When you use websockets, here is what is happening:
The user makes a request to your server
Your server responds with a single response
The response contains Javascript code that will connect your user browser to a websocket server (and this one can work in real time)
The websocket server can trigger events and send them to your user browser. You can then use Javascript in order to make the updates in your views.
Laravel provides a wrapper to use websockets, Laravel Echo.
If you want to know more, I strongly encourage you to read the documentation about it: https://laravel.com/docs/5.4/broadcasting#installing-laravel-echo
Here is a video from Laracasts introducing Laravel Echo also, if you don't like to read documentation: https://laracasts.com/lessons/introducing-laravel-echo

How web-services handle requests and responses, and how PHP could access this correctly?

I'm having troubles to figure out how web services handle requests and send responses, and how my site/module will handle it. So these are my questions and bellow a little about why i am asking this:
What is the right way to send a request to web service?
How a web-service will usually answer a site requesting?
How a PHP site can send a request to a web-service? Is cURL the right way?
I'm a student who are learning PHP and a lot of other things, and my job now is create a Joomla Module to show information from a web service (probably created in java or something, probably created by me, when i learn java...).
I know i will use http requests to talk with the web service, but i worry im using it wrong (making a request to the url, like the browser).
So, i did a little example site and a example API. The api uses Slim microframework to create routes, access my database and return the content in json (what means: if i access 'api.com/api/something' in my browser i see a plain white page with a lot of json). I pretend this is my web service.
The example site send a request to the API with cURL, reads the content and decode the json and do things. It seems forced to me.
I have not much support to understand web services and if i am in the right way (or far from this).
I would appreciate your help.
You are on the right track. A web service is simply a processing or storage facility intended to be accessed by some other program just like a database or fileserver service.
What is the right way to send a request to a web service
It depends. The most common implementations use SOAP or REST which define additional semantics on top of the HTTP protocol. SOAP uses a single URL as a gateway to the service and more specific selection of the functionality and the relevant data is embedded within an XML payload presented via POST. HTTP is merely a bearer for the message exchange. In REST, the HTTP part is integrated into the semantics of the transaction.
The URL identifies the location of the data (or processing function)
The payload contains only data, usually presented as POSTed JSON or XML,
further REST uses the HTTP verb (GET, POST, PUT, DELETE) to indicate the requested action
the HTTP headers are used to convey transaction meta-data.
How a web service will usually answer a request
I'm not sure what you are asking here. It should report back on the state of the request, any relevant error messages and possibly some data.
The speciifics would be unique to the API and documented.
Is cURL the right way?
While it is possible to do a lot with the HTTP wrappers functionality in PHP, libcurl offers an lot more flexibility. So, yes this it would be hard to implement a REST client without using cURL, OTOH a SOAP client is (usually) less complex at the HTTP tier but life is a lot simpler if you use a SOAP library/framework to abstract the more complex protocol.
For future questions please have one question per entry.
What is the right way to send a request to web service?
That really depends on the web service, what they require. It can be as simple as a short text string, to sending a XML formatted or JSON formatted array. You need to research the relevant web service.
How a web-service will usually answer a site requesting?
Again it depends on the web service. They are not the same. A web service will have documentation on what it expects and how it will respond.
How a PHP site can send a request to a web-service? Is cURL the right way?
Curl is a good method and is usually the method used from within PHP.

Login from android to php server

I'm starting a new application that will have a server side PHP and client in Android another (at the moment, and then also probably iphone). The application will only be used from mobile customer applications ie not to be used by web. My question is what would be the best way to login to this mode of operation?
thank you very much
It sounds to me as if the server side will be some sort of API that opens up access to a users data. The easiest method would be sending along a stored username and password with each request. This would only work if the connection your using is secure (https) which brings in the hassle of obtaining an ssl certificate.
Another option would be using OAuth, though your use case seems a little bit different than the standard OAuth use-case. OAuth is a protocol that uses a token based system to establish a users permission to access certain data from an application by another application. In your case you would be in control of both the first and the second application (hence my remark on being different than the standard use-case) Read here for more info.
I think it will be more easier if you use a webservice to make this connection between android and php server
this Presentation may help you ..
you are gonna deal with SOAP and xml or JSON to send data from android to php server.
and this a Video that shows how to deal with REST android Apps.
hope that help.
I think building an API on the server-side would be the best approach. For example a simple REST endpoint might be the way to go.
You can also host the API over HTTPS so that the communications channel is secure.
you need to create PHP web service for that. and while accessing you can pass security key like IMEI of phone for log. I think it can be secured mode for login from Android Phone.
Best practice these days is to set up a simple JSON web service, and use the built in Android HTTP & JSON libraries to interact with this service.
Create a login page in android, take the values from the fields send those values to server using httppost there store in your database and send response from the server
i think you first make a login form on Php server and send it the login and password as soon as user types and php returns the JSON object then read it if login is accepted by server login to application.
another way is when user don't have the net access make some Content providers on android and store the user pass there and match from there locally.

Is there any other way to create an application in google app engine?

I want to create an application in google app engine using php,
Is there any way to login in to my google account using php and create an application dynamically.
Currently, the only way I know to create an app engine app via PHP is through Quercus, the PHP implementation on top of the JVM, as per this post.
Edit: that was "create an app" in the sensible sense of the words -- the running code, simple configuration, data files, &c, that together make up an app -- back when the question was short and ambiguous.
As the question has now been clarified as being instead a quest to violate google's terms and conditions by automating an administrative operation in breach of section 2.3 ("""2.3. You agree not to (a) access (or attempt to access) the administrative interface of the Service by any means other than through the interface that is provided by Google in connection with the Service"""), the case is very different -- my response to that request I'll leave in a comment on this answer.
It seems Google provides no way to automatically create apps on their App Engine.
But as long as you can do it from a browser, you can simulate the app registering process with http queries, using cURL for instance, in PHP.
cURL allows you to send http queries, optionnally with POST data, cookies, etc...you can also set a user-agent. You can pretty much emulate every browser's behaviours. Here, you will have to make a POST query containing the data you're supposed to have filled in the app registering form.
More on cURL on the PHP doc, and there's even a StackOverflow tag for it.

Categories