\AmfphpJson

Enables amfPHP to receive and reply with JSON This plugin can be deactivated if the project doesn't need to support JSON strings and returned as JSON strings using POST parameters.

You must add the 'application/json' content type, or set it in the headers so that it is recognized as a call to be handled by this plugin. for example: http://yourserver.com/Amfphp/?contentType=application/json

Here is some sample code using Javascript with JQuery: var callDataObj = {"serviceName":"PizzaService", "methodName":"getPizza","parameters":[]}; var callData = JSON.stringify(callDataObj); $.post("http://yourserver.com/Amfphp/?contentType=application/json", callData, onSuccess);

Requires at least PHP 5.2.

Summary

Methods
Properties
Constants
__construct()
filterHandler()
deserialize()
handleDeserializedRequest()
handleException()
serialize()
No public properties found
JSON_CONTENT_TYPE
No protected methods found
$returnErrorDetails
N/A
No private methods found
No private properties found
N/A

Constants

JSON_CONTENT_TYPE

JSON_CONTENT_TYPE

the content-type string indicating a JSON content

Properties

$returnErrorDetails

$returnErrorDetails : boolean

return error details.

Type

boolean

Methods

__construct()

__construct(array $config)

constructor. Add filters on the HookManager.

Parameters

array $config

optional key/value pairs in an associative array. Used to override default configuration values.

filterHandler()

filterHandler( $handler, String $contentType) : \this

If the content type contains the 'json' string, returns this plugin

Parameters

$handler
String $contentType

Returns

\this —

or null

deserialize()

deserialize(array $getData, array $postData, string $rawPostData) : string

deserialize

Parameters

array $getData
array $postData
string $rawPostData

Returns

string

handleDeserializedRequest()

handleDeserializedRequest(array $deserializedRequest, \Amfphp_Core_Common_ServiceRouter $serviceRouter) : \the

Retrieve the serviceName, methodName and parameters from the PHP object representing the JSON string call service

Parameters

array $deserializedRequest
\Amfphp_Core_Common_ServiceRouter $serviceRouter

Returns

\the —

service call response

handleException()

handleException(\Exception $exception) : mixed

don't format; just throw! In this way ajax libs will have their error functions triggered

Parameters

\Exception $exception

Returns

mixed —

an object describing the error, that will be serialized and sent back to the client

serialize()

serialize(mixed $data) : \the

Encode the PHP object returned from the service call into a JSON string

Parameters

mixed $data

Returns

\the —

encoded JSON string sent to JavaScript