Current location: Hot Scripts Forums » Programming Languages » PHP » How to select a transaction of an array and check it on regular basis

How to select a transaction of an array and check it on regular basis

 
Prev Previous Post   Next Post Next
  #1  
Old 12-28-06, 06:27 PM
Oskare100 Oskare100 is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
How to select a transaction of an array and check it on regular basis

Hello,
I know that this is maybe a bit complicated but I thought I could take a chance and see if someone had time to read it trough. I need help with the whole script but the main thing is How to select just one transaction of all transactions ebay is returning (see the code sample, in the end of it). I'm working on a script that will be able to "GetFeedback" to see if a user has left positive feedback and then "LeaveFeedback" positive if the feedback left was positive. Everything is built on XML, here is the functions described at ebay;

http://developer.ebay.com/DevZone/XM...tFeedback.html
http://developer.ebay.com/DevZone/XM...eFeedback.html

Unfortunately there are not many code samples at Ebay (but all codes looks the same because it is just send and receive with different variables). Below is the sample code for searching, but I've tried to edit it and it also works the same for all other Ebay API functions. So when I request "GetFeedback" the script returns the variables in that function instead and my script creates an array with the the feedback I've received and (because I don't know how to make it do anything else) creates a table in HTML with all those iteams.

I need to "select" a feedback. Then I need to get all the information about it and assignt PHP variables to them as for example $transaction_id_awaiting for the transaction id, $user_id_awaiting for the user id of that transaction and so on. Because then I need those variables to be able to use the "LeaveFeedback" function to leave feedback for that transaction/user.

Another thing is that the script can't select the same feedback/transaction from "GetFeedback" all the time because then script would loop to the next feedback is left. It should only select feedbacks/transactions that the script already hasn't left feedback for. Maybe I could store the for example 30 latest feedbacks that has been answered in a table in my database, only make Ebay return the 30 latest feedbacks left for me and then fist check the table before leaving feedbacks?

Here is the code sample;
PHP Code:
<?php
    
if(isset($_POST['Query']))
    {
        
//Get the query entered
        
$query $_POST['Query'];
    
    
        
//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 'GetSearchResults';
        
//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);
        
        
///Build the request Xml string
        
$requestXmlBody '<?xml version="1.0" encoding="utf-8">';
        
$requestXmlBody .= '<GetSearchResultsRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
        
$requestXmlBody .= "<RequesterCredentials><eBayAuthToken>$userToken</eBayAuthToken></RequesterCredentials>";
        
$requestXmlBody .= "<Query>$query</Query>";
        
$requestXmlBody .= '</GetSearchResultsRequest>';
        
        
$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 rrror 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('Item');
            
            
//see if there are any results
            
if(count($itemNodes) > 0)
            {
            
?>
                <TABLE cellpadding="6" cellspacing="0" border="0">
                    <TR bgcolor="#BBBBBB">
                        <TD><B>Id</B></TD>
                        <TD><B>Title</B></TD>
                        <TD><B>Price</B></TD>
                        <TD><B>Started</B></TD>
                        <TD><B>Ends</B></TD>
                    </TR>
            <?php
                
//stores the alternationg background colour of the rows
                
$bgColor "#FFFFFF";
                
//go through each result
                
foreach($itemNodes as $item)
                {
                    
//get the required nodes from the results
                    
$itemID $item->get_elements_by_tagname('ItemID');
                    
$title $item->get_elements_by_tagname('Title');
                    
$price $item->get_elements_by_tagname('CurrentPrice');
                    
$startTime $item->get_elements_by_tagname('StartTime');
                    
$endTime $item->get_elements_by_tagname('EndTime');
                    
$link $item->get_elements_by_tagname('ViewItemURL');
                    
//display the result in a table row
                    
?>
                    <TR bgcolor="<?php echo $bgColor ?>">
                        <TD><?php echo $itemID[0]->get_content(); ?></TD>
                        <!-- Display the Title as a link to the item on eBay -->
                        <TD><A href="<?php echo $link[0]->get_content(); ?>" target="_blank">
                            <?php echo $title[2]->get_content(); ?>
                            </A>
                        </TD>
                        <TD><?php echo $price[0]->get_content(); ?></TD>
                        <TD><?php echo $startTime[0]->get_content(); ?> GMT</TD>
                        <TD><?php echo $endTime[0]->get_content(); ?> GMT</TD>
                    </TR>
                    <?php
                    
//alternate the background colours
                    
$bgColor $bgColor == "#FFFFFF" "#EEEEEE" "#FFFFFF";
                } 
?>
                </TABLE>
                <?php
            
}
            else
            {
                echo 
'<P><B>No items found</B>';
            }
        }
    }
?>
/Oskar

Last edited by Oskare100; 12-28-06 at 06:48 PM.
Reply With Quote
 

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
RSS Using RSS2Html Script VKX PHP 1 10-16-06 06:27 PM
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 04:54 PM
file into an array, then appending array only if no duplicates djpennin Perl 2 05-17-04 02:04 PM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 05:28 PM


All times are GMT -5. The time now is 06:03 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)