I'm using PHP to connect to an API and register some info using JSON and HTTP POST but it is not going well.
That is what I do:
-
I create a JSON object with the json_encode function:
$name = 'Mike'; $surname = 'Hans'; $fields = array('name' => json_encode($name), 'surname' => json_encode($surname)); $postData = json_encode($flds);
Once i have the post data, I just connect to the API with curl and login with oauth, but the API responde says:
JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this)
I have checked the allow_nonref in Google, but i could not find anything for PHP, all I have found is for Perl. Does anyone have any solution/advice to solve this?
Thanks!