Oh, Here's the script that I want to input the content into:

<?php
/*
 * The Standard Industrial Classification Codes that appear in a
 * company's disseminated EDGAR filings indicate the company's type
 * of business.
 *
 * These codes are also used in the Division of Corporation Finance as
 * a basis for assigning review responsibility for the company's filings.
 * For example, a company whose business was Metal Mining (SIC 1000)
 * would have its filings reviewed by staffers in A/D Office 9.
 *
 * @link http://www.sec.gov/info/edgar/siccodes.htm
 */

$sic_codes = file_get_contents('./sic_codes.txt');

$sic_lines = explode("\n", $sic_codes);

$sic = array();
foreach ($sic_lines as $cnt => $sic_code) {
    $tmp = trim($sic_code);
    $tmp = explode("\t", $tmp);
    foreach($tmp as $tmptmp) {
      $tmp[] = trim($tmptmp);
    }
    $tmp['cnt'] = $cnt;


    //print_r($tmp);
    //print "---\n\n";

    /*
    if ($cnt > 0) {
      $sic[] = array(
        'industry_title' => $tmp[3],
        array(
          'sic'       => $tmp[0],
          'ad'      => $tmp[1]
        )
        );
    }
    */

    $tmp[0] = trim($tmp[0]);
    $sic[$tmp[0]] = $tmp[3];

    /* Data to Save to CakePHP Admin Backend */
    $data['StandardIndustrialClassificationCode']['sic'] = trim($tmp[0]);
    $data['StandardIndustrialClassificationCode']['industry_name'] =
trim($tmp[3]);

    print_r($data);
    //print json_encode($data);
    //print "\n\n\n";
    unset($data);
}

//print_r($sic);

The output of that script that I would like to feed into via curl -X POST
http://192.168.1.100/cake_2_0/standard_industrial_classification_codes.xml :


>php -f "sic_codes.php"
Array
(
    [StandardIndustrialClassificationCode] => Array
        (
            [sic] => SIC
            [industry_name] => INDUSTRY_TITLE
        )

)
Array
(
    [StandardIndustrialClassificationCode] => Array
        (
            [sic] => 100
            [industry_name] => AGRICULTURAL PRODUCTION-CROPS
        )

)
Array
(
    [StandardIndustrialClassificationCode] => Array
        (
            [sic] => 200
            [industry_name] => AGRICULTURAL PROD-LIVESTOCK & ANIMAL
SPECIALTIES
        )

)
Array
(
    [StandardIndustrialClassificationCode] => Array
        (
            [sic] => 700
            [industry_name] => AGRICULTURAL SERVICES
        )

)
On Wed, Nov 9, 2011 at 12:27 AM, Matthew Kaufman <[email protected]> wrote:

> Hello,
>
> Setting up REST is always frustrating for me at first honestly in Cake.  I
> prefer to interact with my applications to add data via Curl on the command
> line;
>
> Let's start out at Step 1 Though:
>
> /app/Config/routes.php:
> ----
> Router::mapResources('training_categories');
> Router::mapResources('central_index_keys');
> Router::mapResources('standard_industrial_classification_codes');
> Router::parseExtensions('json', 'xml');
>
> /app/Controllers/StandardIndustrialClassificationCodesController.php
> ----
> class StandardIndustrialClassificationCodesController extends
> AppController
> {
>     var $components = array('RequestHandler');
>
> /**
>  * index method
>  *
>  * @return void
>  */
>     public function index() {
>         $this->StandardIndustrialClassificationCode->recursive = 0;
>         $this->set('standardIndustrialClassificationCodes',
> $this->paginate());
>         $this->set('standard_industrial_classification_codes',
> $this->paginate());
>
>         //$standard_industrial_classification_codes =
> $this->StandardIndustrialClassificationCode->find('all');
>         //$this->set(compact('standard_industrial_classification_codes'));
>     }
>
> ------------------------------------------------------------------------
>
> root@mkfmnweb:/var/www/cake_2_0/app/View# cat
> StandardIndustrialClassificationCodes/xml/index.ctp
> <?php
> // app/views/standard_industrial_classification_codes/xml/index.ctp
> ?>
>
> <standard_industrial_classification_codes>
>     <?php $xml->serialize($standard_industrial_classification_codes); ?>
> </standard_industrial_classification_codes>
>
>
> root@mkfmnweb:/var/www/cake_2_0/app/View#
>
> ------------------------------------------------------------------------
>
> Anyway, when I try to access
> http://192.168.1.100/cake_2_0/standard_industrial_classification_codes.xmlit 
> should render properly; but now it tells me that I have an undefined
> variable; or "Call to a member function serialize() on a non-object in my
> StandardIndustrialClassificationCodes/xml/index.ctp on line 6" ----
> Attatching a screenshot to this message.
>
> How can I setup basic REST?
>
> Another thing I would like to know is how can I best lay out in the
> controller to support basic Browser based form INSERT's
> (Controller/StandardIndustrialClassificationCodeController.php > add())
> with the scaffold generated HTML form view as well as doing a curl -X POST
> to http://server/cake_2_0/standard_industrial_classification_codes/*
> add.xml* with the data inputted from their sent in with XML headers on
> it?  That is my secondary question.
>
> First question is how can I get the new Cake to list me out my nice XML?
> :).
>
> Thanks,
> Matt Kaufman
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to