Skip to content

Instantly share code, notes, and snippets.

@stuffmc
Created July 23, 2014 20:49
Show Gist options
  • Save stuffmc/194753a33748e21dc761 to your computer and use it in GitHub Desktop.
Save stuffmc/194753a33748e21dc761 to your computer and use it in GitHub Desktop.
// curl -X POST -H "Content-Type: body=application/json" -d '{"logs":["xyz"]}' https://example.com/v1/log
$cont = file_get_contents('php://input');
echo "cont: $cont\n"; // Outputs cont: {"logs":["xyz"]}
$log = json_decode($cont);
echo "log: $log\n"; // Never outputed. Even not "log:"
@stuffmc
Copy link
Author

stuffmc commented Jul 23, 2014

Thanks guys!!!

@PofMagicfingers
Copy link

@loicm : That's not the issue here. Issue was getting $log to echo

@loicm
Copy link

loicm commented Jul 23, 2014

@PofMagicfingers this was because he wanted to access the object as a string as he didn't know how to deal with objects in php. But agree that it's error level didn't help him to debug as the error went silently…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment