Welcome Guest, Not a member yet? Register   Sign In
XML-RPC - Building a catalog from an external XMLDataStream
#1

[eluser]ModernM[/eluser]
Hello Codeigniter,

I had a general question on a project I am about to begin. Its a personal project that, but hopefully I will gain a wealth of knowledge as I execute this.

I need to know some basics about how I should proceed sprinkled with some tech talk to make sure I am heading in the right direction here.

I am going to use code igniters XML-RPC to send requests to a server that has a catalog XML data stream. I was provided documentation and I have read through it, and I do understand for the most part everything that is in there. I was also provided some XML file as examples.

XMLCatReq
Code:
<XMLDataStreamRequest>
<Ver>3.1</Ver>
<Auth>
<AcctID>9000</AcctID>
<LoginID>TestXMLDSUser</LoginID>
<Password>abc123</Password>
</Auth>
<CategoryList>
<GetList>1</GetList>
<Sort>NAME</Sort>
</CategoryList>
&lt;/XMLDataStreamRequest&gt;

and a XMLCatReqResponse

Code:
&lt;?xml version="1.0"?&gt;
&lt;XMLDataStreamResponse&gt;
<Ver>3.1</Ver>
<LegalNote>USE</LegalNote>
<CategoryList>
<Category>
<Num>224</Num>
<Name>Address Books</Name>
</Category>
<Category>
<Num>742</Num>
<Name>Adhesives</Name>
</Category>
</CategoryList>
&lt;/XMLDataStreamResponse&gt;

I am familiar with working with MVC, but never with XML. Could someone give me a kick start here and also valid or invalidate that I am looking at this correctly and if not please provide me some direction.

Maybe if someone can put a simple example together for me so I can see how codeigniter and the XML above translate into one another that would be huge.

I am not asking you to build me the entire project just a little nudge in the right direction.

Much Appreciated.
#2

[eluser]ModernM[/eluser]
Well after a day of fiddling with the XML RPC I have read that the format of the post and get structure of the XML is very tight and not flexible. I am able to knock on the door so to speak with the xML rPC but i need to send specific information to the service(datastream) in order to get back a responses.

Here is where I am at.
http://screen.modernmgrp.com/catalog/cat

Hopefully someone can help me out here, i think I need to come at this another direction but I have no idea where to start. According to the dev manual for the data feed I need to POST the data shown in the XML format they provide. I havent worked with XML and PHP enough to send it anywhere so I am a bit stuck.

Hopefully someone can shed some light on this for me. Give a man a fish feed him for a day, teach a man to fish feed him for life. I am learning to fish I know, just need to know what bait to use and what pole, and I think I can sort out the rest slowly.

Smile
#3

[eluser]ModernM[/eluser]
moving along, went to cURL to get the data, now I am trying to build the catalog from the return of the raw XML. Tried using CSS but I have images I need to setup.

Anyone out there willing to guide me in the right direction.
#4

[eluser]Matalina[/eluser]
PHP5 has a wonderful tool simplexml

Here's a decent tutorial: http://www.phpro.org/tutorials/Introduct...h-PHP.html
#5

[eluser]ModernM[/eluser]
Thank you! I'll try this doc after lunch. I think I'm sooooo close yet so far away. Smile
#6

[eluser]ModernM[/eluser]
So I read through the material, and yes i think this will work. When I do the demo on the site I can pull through the XML data, but when I try to load my data in I only get 3 returns.

Now I suspect it might be that I am using cURL to post the requests and then its coming back in the variable $res. Could it be that I have too much in one controller trying to get the data and then parse it?

Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Catalog extends CI_Controller {


function index(){

  //$catid = $_GET['catid'];
  $catid = 'aprons';
  //echo 'This is the cat ID called by the URL => '.$catid;
  
  $post = '&lt;?xml version=\“1.0\” encoding=\“UTF-8\”?&gt;\n\n';
  $post .= '&lt;XMLDataStreamRequest&gt;\n';
  $post .= '<Auth>\n';
  $post .= '<AcctID>123</AcctID>\n';
  $post .= '<LoginID>login</LoginID>\n';
  $post .= '<Password>pass</Password>\n';
  
  $post .= '<Search>\n';
  $post .= '<Category>'.$catid.'</Category>\n';
  $post .= '</Search>\n';
  $post .= '&lt;/XMLDataStreamRequest&gt;\n';
  
  //theme
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,'https://www.promoplace.com/ws/ws.dll/XMLDataStream');
  curl_setopt($ch, CURLOPT_POST, TRUE);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  $res = curl_exec($ch);
  curl_close ($ch);
  
  //echo $res;
  
  if( ! $xml = simplexml_load_string($res) )
   {
    echo 'Unable to load XML string';
    
    }
    else
    {
     foreach( $xml as $Item )
     {
      echo 'PrName: '.$Item->PrName.'<br />';
      }
      
      }
  

   //$data['list_view'] = $res;
   //$this->load->view('list_view', $data);
  
  
  }



}

Whats returned is
PrName:
PrName:
PrName:

Any ideas?

Again, thank you very much for your help, teaching a man to fish.




Theme © iAndrew 2016 - Forum software by © MyBB