Getting remote data - PHP or javascript? -


For example, what method would you choose to retrieve Tweets from Twitter?

  • Using json with jQuery (like), where the client requests.
  • Using PHP for example Curl, where server requests

What are the advantages / disadvantages of both?

There is a difference between both methods when you use the server side outside of HTTP requests You recover the data on the server. If you want the data to be viewed by the customer, you have to send it with the next request, which the client does for your server side, with server side requests you can also make original HTTP requests and cross-domain requests.

The client-side cross-domain request retrieves data directly from the client. When you want data on the server side (to store tweets in DB) you have to send them back to the customer, you can display the client in the same example in the example when the request returns the data Javascript can not request cross-domain XHR on the server To do this, you (or Libs who do this) make some workmen: using iframes, which by using JS files Areas already have the information, and more.

If you use web services, I use backend as a service customer and advise to use the bridge over time with client side or use some "comet" techniques.


Comments