JSON in POST to notify_url

Archived from the Transloadit support forum. Originally posted on January 25, 2011; details may be outdated, see our docs for current behavior. Original thread

For some reason, I am unable to decode the json posted to my notify_url.

This is the PHP code I am using:

$json = json_decode($_POST[‘transloadit’],true);

If I copy/paste the JSON string from the log file (var_dump of $_POST) I can get it to decode it, but not with the code above.

Am I missing something?

http://api2.vivian.transloadit.com/assemblies/REDACTED

Is an example assembly that didn’t work with that code.

I actually figured it out:

$clean = str_replace(‘\"’,‘"’,$_POST[‘transloadit’]); $json = json_decode($clean,true);

Maybe there’s a more elegant way… but this works.

$clean = str_replace(‘"’,‘"’,$_POST[‘transloadit’]); $json = json_decode($clean,true);

This looks like you have magic quotes enabled? The best solution would be to disable them.

Otherwise you should use stripslashes. Also, our PHP SDK can do this job for you as well:

$response = Transloadit::response()

--fg

Ah.. that makes sense. Thanks for the advice.

Alright, closing this now. Feel free to re-open if you have more questions about this!