Siddharth
Siddharth

Reputation: 5219

Making REST API on Google App engine

I have a PHP web application and I want to make a comments section for the same. So, I have decided to do it this way-

Make a Python web application to store comments and retrieve comments from the BigTable. I'd make an AJAX request to store a comment (along with the comment and other parameters) and make an AJAX request to get all the comments from the BigTable in a JSON format (Is it possible to return formatted HTML directly so that I can just replace a div in the parent page which makes the request).

The problem here is that the PHP web application is running on a different domain and I am not sure whether I can make AJAX calls - does this violate the cross-domain security policy. If yes, then how does REST based APIs work - where I can make AJAX requests to and get the JSON in response.

Ideally, I'd like to return formatted HTML directly from GAE. But if that is not possible, I'm fine with returning JSON.

Can this be done? If yes, any pointers on how to make an API like this would be useful. If no, what are the workarounds?

Upvotes: 0

Views: 912

Answers (2)

w3core
w3core

Reputation: 139

Take a look at RockWall REST API engine.

Basic useful feature list:

  • Multiple requests (REST API) via single HTTP request.
  • Unified and stable response format for all requests.
  • Endpoint method execution by dependency of type detection (static or whether not).
  • Request modifiers feature.
  • Allows to declare which type of class instance should be used for each request (New instance, Singleton or new instance of Singleton).
  • Cross-domain AJAX requests support.
  • ...and more...

Upvotes: 0

Drew Sears
Drew Sears

Reputation: 12838

Most browsers don't permit cross-origin XHR. The general workaround for this is JSONP, which basically means using a script tag to invoke remote javascript, which passes response data into a local callback.

There's nothing App Engine-specific about this problem or solution.

Upvotes: 2

Related Questions