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 http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 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.

Add a comment

Warning!

This content
is outdated.

Discover Silex v2,
online website builder.

Upcoming Events

  1. Haxetelier #8 : Trucs et Haxetuces

    October 29 @ 7:00 pm - 9:00 pm

Sign up for Silex Labs news by email

SilexLabs community Tweets