title: "JSON text must be an object or array" error
body: <p>I'm using PHP to connect to an API and register some info using JSON and HTTP POST but it is not going well.</p>
  
  <p>That is what I do:</p>
  
  <ol>
  <li><p>I create a JSON object with the json_encode function:</p>
  
  <pre><code>$name = 'Mike';
  
  $surname = 'Hans';
  
  $fields = array('name' =&gt; json_encode($name), 'surname' =&gt; json_encode($surname));
  $postData = json_encode($flds);
  </code></pre></li>
  <li><p>Once i have the post data, I just connect to the API with curl and login with oauth, but the API responde says:</p></li>
  </ol>
  
  <blockquote>
    <p>JSON text must be an object or array (but found number, string, true,
    false or null, use allow_nonref to allow this)</p>
  </blockquote>
  
  <p>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?</p>
  
  <p>Thanks!</p>