Current location: Hot Scripts Forums » Programming Languages » PHP » Need help with small PHP XML API problem fast! Please help! Can eventually pay!

Need help with small PHP XML API problem fast! Please help! Can eventually pay!

Reply
  #1 (permalink)  
Old 04-11-07, 08:15 AM
Oskare100 Oskare100 is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Need help with small PHP XML API problem fast! Please help! Can eventually pay!

Hello,
I'm currently using this page to get information about the buyers email, Ebay status and the Ebay transaction ID of a transaction at Ebay. The problem is that I also need to get some more information from the XML reply, but I don't know how to do it.

Here is the page:
PHP Code:
<?php   
if ($_POST['itemid'] == ""){

    print 
"<form name='form1' method='post' action='GetItemTransactionss.php'>";
    print 
"<input name='itemid' type='text' id='itemid'>";
    print 
"<input name='userid' type='text' id='userid'>";
    print 
"<input type='submit' name='Submit0' value='Post'>";
}
else { 
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 'GetItemTransactions';
    
//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);
    
    
$item_number=$_POST['itemid'];
    
$user_id=$_POST['userid'];

    
// Time from and time to
    
$time_from date('Y-m-d\TH:i:s',strtotime("-28 days")).'.799Z';
    
$time_to date('Y-m-d\TH:i:s',strtotime("+1 days")).'.799Z';
    
    
///Build the request Xml string
    
$requestXmlBody '<?xml version="1.0" encoding="utf-8"?>';
    
$requestXmlBody .= '<GetItemTransactionsRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
    
$requestXmlBody .= "<RequesterCredentials><eBayAuthToken>$userToken</eBayAuthToken></RequesterCredentials>";
    
$requestXmlBody .= "<ItemID>$item_number</ItemID>";
    
$requestXmlBody .= "<ModTimeFrom>$time_from</ModTimeFrom>";
    
$requestXmlBody .= "<ModTimeTo>$time_to</ModTimeTo>";
    
$requestXmlBody .= '</GetItemTransactionsRequest>';
    
    
$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
$transactionNodes $responseDoc->get_elements_by_tagname('Transaction');
    
$transaction_id=-1;
foreach (
$transactionNodes as $key=>$node){
  
$buyer=$node->get_elements_by_tagname("Buyer");
  
$userid=$buyer[0]->get_elements_by_tagname("UserID");
  if(
$userid[0]->get_content()==$user_id$transaction_id=$key;
}

if(
$transaction_id!=-1){
  
$transaction=$transactionNodes[$transaction_id]->get_elements_by_tagname("TransactionID");
  
$ebay_transaction_id $transaction[0]->get_content();

  
$ebaystatus=$transactionNodes[$transaction_id]->get_elements_by_tagname("Status");
  
$ebay_status $ebaystatus[0]->get_content();
  
  
$ebayemail=$transactionNodes[$transaction_id]->get_elements_by_tagname("Email");
  
$ebay_email $ebayemail[0]->get_content();
  
  echo 
"$ebay_transaction_id";
  echo 
"$ebay_status";
  echo 
"$ebay_email";
  


    }
    }
?>
Here is the structure of the reply from Ebay: http://developer.ebay.com/DevZone/XM...nsactions.html .

I need to be able to get information from different places of the transaction part of the XML reponse, not just from "buyer" as for example I need to get <ExternalTransactionID> from <ExternalTransaction> and the <PaidTime> and similar from that <transaction> with that <UserID> . So I can be able to use the different levels, as for example to get TransactionArray.Transaction.Buyer.BuyerInfo.Shipp ingAddress.Name for that user and transaction.

I've tried for several hours now to get this to work, so please, help me! If you PM your Paypal email I'll also leave compensation for your time if it works - I really need this to work.

Thanks in advance,
/Oskar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-13-07, 05:38 AM
darkerstar's Avatar
darkerstar darkerstar is offline
Newbie Coder
 
Join Date: Apr 2007
Location: London
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Is your above scripts working?

If it is and I don't see why you can't get it to read what you wanted. The code pretty much shows how to read data from different XML branches.
__________________
Read Tiaon Lab blog
PHP + Delphi programming
http://www.tiaon.com/wordpress/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-16-07, 11:48 AM
Oskare100 Oskare100 is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,
Yes, it is working, the problem is that I can't get it to extract other information from the XML reply. Could you please help me with that?

Best Regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Downside--Solutions? Amulet PHP 10 07-15-05 09:26 AM
php variable problem ashishjha54 PHP 7 05-22-05 01:09 PM
xml problem plz help me EvilDeveloper PHP 0 05-11-05 12:53 AM
PHP script required, willing to pay! jamesian Job Offers & Assistance 1 10-28-04 12:32 PM
Can anyone help me ? (problem using php variables in html db insert code) chronic_ PHP 2 06-13-04 12:19 PM


All times are GMT -5. The time now is 03:07 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.