Web Design and Development Forums

XML/PHP API Question! Solved one part need help with selecting!

This is a discussion on "XML/PHP API Question! Solved one part need help with selecting!" within the XML, RSS & Atom section. This forum, and the thread "XML/PHP API Question! Solved one part need help with selecting! are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > XML, RSS & Atom

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Apr 19th, 2007, 18:55   #1 (permalink)
New Member
 
Join Date: Apr 2007
Location: on the net
Posts: 1
XML/PHP API Question! Solved one part need help with selecting!

Hello,
I've managed to recieve all messages from Ebay within the data range I specified with the call GetMemberMessages (http://developer.ebay.com/DevZone/XM...rMessages.html) but I have one problem left I really need help with.

Here is the code I used:
PHP: Select all

<?php   
include('functions.php');
include(
'variables.php');
error_reporting(E_ALL);
ini_set('display_errors''1');
    
//SiteID must also be set in the Request's XML
    //SiteID = 0  (US) - UK = 3, Canada = 2, Australia = 15, ....
    //SiteID Indicates the eBay site to associate the call with
    
$siteID 0;
    
//the call being made:
    
$verb 'GetMemberMessages';
    
//Regulates versioning of the XML interface for the API
    
$compatabilityLevel 433;

    
//get an array of strings containing the required headers
    
$headers buildEbayHeaders($devID$appID$certID$compatabilityLevel$siteID$verb);

    
// Time from and time to
    
$time_from date('Y-m-d\TH:i:s',strtotime("-10 days")).'.799Z';
    
$time_to date('Y-m-d\TH:i:s',strtotime("+ 1 day")).'.799Z';
    
    
///Build the request Xml string
    
$requestXmlBody '<?xml version="1.0" encoding="utf-8">';
    
$requestXmlBody .= '<GetMemberMessagesRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
    
$requestXmlBody .= "<RequesterCredentials><eBayAuthToken>$userToken</eBayAuthToken></RequesterCredentials>";
    
$requestXmlBody .= "<MailMessageType>All</MailMessageType>";
    
$requestXmlBody .= "<EndCreationTime>$time_to</EndCreationTime>";
    
$requestXmlBody .= "<StartCreationTime>$time_from</StartCreationTime>";
    
$requestXmlBody .= '</GetMemberMessagesRequest>';
    
    
$responseXml sendHttpRequest($requestXmlBody$serverUrl$headers);
    if(
stristr($responseXml'HTTP 404') || $responseXml == '')
        die(
'<P>Error sending request');
    
    
//Xml string is parsed and creates a DOM Document object
    
$responseDoc domxml_open_mem($responseXml);
    
    
//get any error nodes
    
$errors $responseDoc->get_elements_by_tagname('Errors');
    
    
//if there are error nodes
    
if(count($errors) > 0)
    {
        echo 
'<P><B>eBay returned the following error(s):</B>';
        
//display each error
        //Get error code, ShortMesaage and LongMessage
        
$code $errors[0]->get_elements_by_tagname('ErrorCode');
        
$shortMsg $errors[0]->get_elements_by_tagname('ShortMessage');
        
$longMsg $errors[0]->get_elements_by_tagname('LongMessage');
        
//Display code and shortmessage
        
echo '<P>'$code[0]->get_content(), ' : 'str_replace(">""&gt;"str_replace("<""&lt;"$shortMsg[0]->get_content()));
        
//if there is a long message (ie ErrorLevel=1), display it
        
if(count($longMsg) > 0)
            echo 
'<BR>'str_replace(">""&gt;"str_replace("<""&lt;"$longMsg[0]->get_content()));

    }
    else 
//no errors
    
{
     
//get results nodes
    
$itemNodes $responseDoc->get_elements_by_tagname('MemberMessage');
    
    foreach(
$itemNodes as $item){
    
$message $item->get_elements_by_tagname('MemberMessageExchange');
                {
                
//display all the elements of each item
                
foreach($item->child_nodes() as $itemChild)
        echo 
$itemChild->get_content();
        
            }
    
    
    }
    
    }
?>
The problem is that when I run that code I get all information back - everything - item numbers, emails, questions and everything else. I've no idea of how to select the information I want to use. That's what I really need help with.

I tried to use echo $itemChild->get_content('SenderEmail'); to get only the sender email but it didn't work, I still got everything back. I'm really greatful for any help I can get.

Thanks in advance,
Oskar R
oskare100 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Aug 16th, 2007, 14:08   #2 (permalink)
Up'n'Coming Member
 
Join Date: Aug 2007
Location: Bicester
Posts: 70
Re: XML/PHP API Question! Solved one part need help with selecting!

Hi Oskar

Code: Select all
foreach($item->child_nodes() as $itemChild)
       echo $itemChild->get_content();
 
           }
$item is the membermessage so when you do $item->child_nodes you'll get the lot. I don't know the datastructure of <MemberMessage> and what element(s) you want. You need a method which selects by tag name. In fact in your code you have just this only it isn't doing anything there:

Code: Select all
$message = $item->get_elements_by_tagname('MemberMessageExchange');
you could try replacing the block I copied at the top of this post with this where 'Email' is the name of the element you want:

Code: Select all
foreach($item->get_elements_by_tagname('Email') as $itemChild)
       echo $itemChild[0]->get_content();
 
           }
I'm not sure if this will work. get_elements_by_tagname returns a list of matching nodes. I would expect this to be just one hence the [0] on the echo line.
I'm happy to help you more but I would need to see if poss the XML for MemberMessage and to know which field(s) you want

It looks like the PHP XMLDOM does not support XPATH which would have solved the problem very easily.


Justin
Kropotkin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
api, ebay, select, soap, xml

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] &lt;c:forEach&gt; question pesho318i JavaScript Forum 2 Dec 16th, 2007 17:26
[SOLVED] A Question? Why does this happen? R8515198 CSS Forum 22 Dec 5th, 2007 01:33
[SOLVED] email question begeiste PHP Forum 8 Oct 3rd, 2007 22:31
[SOLVED] Meta Tag Question euankennedyimorph HTML Forum 2 Oct 1st, 2007 07:46



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 23:08.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59