Skip to content

Instantly share code, notes, and snippets.

@tkreis
Created June 19, 2013 16:36
Show Gist options
  • Save tkreis/5815752 to your computer and use it in GitHub Desktop.
Save tkreis/5815752 to your computer and use it in GitHub Desktop.
fixing Zendesk POST parameter in php

When trying to get requests from the zendesk via their proxy it sends them in the following fashion:

body:{"user_id":"50","api_key":"XXX"}

PHP will have problems parsing the request header and stuffing it into the global $_POST variable. To get it to work you can use the following snippet. This returns an array, just like you would normally expect:

get_object_vars((json_decode(file_get_contents("php://input"))));

If your using something like zf, then you can link it to the request object like so:

$params_as_array = get_object_vars((json_decode(file_get_contents("php://input"))));
$request->setParams($params_as_array);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment