Using Alternative Data Formats(JSON, etc.)

The default data format for Amfphp is AMF. However Amfphp looks at the content type header to see if the request should be handled differently. For example if no content type is detected, the service browser plugin assumes that the request is coming from a Web browser and handles the request instead. There are 2 ways to inform Amfphp about the content type:

  • using the Content-Type HTTP header. See the section « 14.17 Content-Type » in for details. Sometimes this fails because of server or client configuration and limitations, which is why there is the alternative below.
  • passing the content type in the URL. For example http://youserver/Amfphp/?contentType=application/json will cause the JSON plugin to handle the request.

Try whatever method works best for you. The examples use the second method as it is easier to read.

See the distributed plugins list and third party plugins exchange to see what data formats are supported. At the time of writing, JSON and JSONP are supported.

Laissez un commentaire

News letter

Evénements Silex Labs sur Paris et sa région: Inscrivez vous à la Newsletter mensuelle

Silex Labs community Tweets

Facebook page