1 Reply Latest reply on Mar 22, 2012 9:30 AM by blassl

    JSON encoding for iOS iPhone app

    JoeScarpetta

      I am working on some php pages for an iphone app that are using $_GET to return css formatted text for an iPhone app in JSON. They work fine in a browser, but developers are saying they are not JSON encoded. Am I missing something?

       

      <?php

      session_start();

      require_once('FileMaker.php');

      require_once('db_info.php');

      $search = $fm->newFindAllCommand('content');

      $searchResult = $search->execute();

       

      if(FileMaker::isError($searchResult)){

      $message = $searchResult->getMessage();

      $error = true ;

       

      }else{

        $foundRecords = $searchResult->getRecords();

      $record = $foundRecords[0];

      $introduction = $record->getFieldunencoded('introduction_css');

      $error = false ;

      $message = "";

      }

       

      $arr = array (

       

      'content' => $introduction,

      'errors' => $error,

      'error_fields' => '',

      'message' => $message

       

      );

       

      ?>

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml">

      <head>

      <meta http-equiv="Content-Type" content="text/json; charset=UTF-8" />

      </head>

      <?php echo json_encode ( $arr ); ?>

      <body>

      </body>

      </html>