Пример #1
0
 public function request()
 {
     require_once '../includes/keys.php';
     require_once '../includes/eBaySession.php';
     $verb = "FetchToken";
     $request_string = file_get_contents("http://" . $_SERVER['SERVER_NAME'] . "/xml/FetchToken.xml");
     $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
     $response = $session->sendHttpRequest($request_string);
     return $response;
 }
Пример #2
0
 function __construct($bidderUserID, $token, $itemID, $maxBid, $quantity = 1, $action = 'Bid', $userConsent = true)
 {
     global $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID;
     // defined in keys.php
     // set up instance variables
     $this->bidderUserID = $bidderUserID;
     $this->itemID = $itemID;
     $this->maxBid = $maxBid;
     $this->quantity = $quantity;
     $this->action = $action;
     // Action is either 'Bid' or 'Purchase'
     // Could cache item as session variable, but better to re-get for freshest info
     $this->itemObj = new SingleItem($itemID);
     // Get a new item
     //the call being made:
     $verb = 'PlaceOffer';
     $myIP = '000.000.0.0';
     // use the client's external IP address
     ///Build the request Xml string
     $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
     $requestXmlBody .= '<PlaceOfferRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
     $requestXmlBody .= "<RequesterCredentials><eBayAuthToken>{$token}</eBayAuthToken></RequesterCredentials>";
     $requestXmlBody .= "<EndUserIP>{$myIP}</EndUserIP>";
     $requestXmlBody .= '<BlockOnWarning>true</BlockOnWarning>';
     /* BEGIN AFFILIATE TRACKING - ONLY SUPPORTED IN PRODUCTION - NOT IN SANDBOX
             $requestXmlBody .= '<AffiliateTrackingDetails>';
             $requestXmlBody .= '  <AffiliateUserID>12345</AffiliateUserID>';       
             $requestXmlBody .= '  <ApplicationDeviceType>Browser</ApplicationDeviceType>';
             $requestXmlBody .= '  <TrackingID>Insert your tracking ID here</TrackingID>';                 
             $requestXmlBody .= '  <TrackingPartnerCode>5</TrackingPartnerCode>';   
             $requestXmlBody .= '</AffiliateTrackingDetails>';
        END AFFILIATE TRACKING - ONLY SUPPORTED IN PRODUCTION - NOT IN SANDBOX */
     $requestXmlBody .= "<ItemID>{$itemID}</ItemID>";
     $requestXmlBody .= '<Offer>';
     $requestXmlBody .= "<Action>{$action}</Action>";
     $requestXmlBody .= "<MaxBid>{$maxBid}</MaxBid>";
     $requestXmlBody .= "<Quantity>{$quantity}</Quantity>";
     $requestXmlBody .= "<UserConsent>{$userConsent}</UserConsent>";
     $requestXmlBody .= '</Offer>';
     $requestXmlBody .= '</PlaceOfferRequest>';
     //Create a new eBay session with all details pulled in from included keys.php
     $session = new eBaySession($devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
     //send the request and get response
     $responseXml = $session->sendHttpRequest($requestXmlBody);
     if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
         die('<P>Error sending request');
     }
     //print "RESPONSE_XML = \n $responseXml \n\n";
     $this->resp = simplexml_load_string($responseXml);
 }
Пример #3
0
function getOrders($devID, $appID, $certID, $compatabilityLevel, $siteID, $userToken, $serverUrl)
{
    //Build the request Xml string
    $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
    $requestXmlBody .= '<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
    $requestXmlBody .= "<RequesterCredentials><eBayAuthToken>{$userToken}</eBayAuthToken></RequesterCredentials>";
    $requestXmlBody .= "<CreateTimeFrom>2011-12-19T20:34:44.000Z</CreateTimeFrom>";
    $requestXmlBody .= "<CreateTimeTo>2012-01-01T20:34:44.000Z</CreateTimeTo>";
    $requestXmlBody .= '<OrderRole>Seller</OrderRole>';
    $requestXmlBody .= '<OrderStatus>All</OrderStatus>';
    $requestXmlBody .= '</GetOrdersRequest>';
    //Create a new eBay session with all details pulled in from included keys.php
    $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, 'GetOrders');
    //send the request
    $responseXml = $session->sendHttpRequest($requestXmlBody);
    if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
        die('<P>Error sending request');
    }
    //return the version
    return $responseXml;
}
Пример #4
0
    public function getSellerTransactions($orderid)
    {
        $handle = new eBaySession($this->token, $this->devID, $this->appID, $this->certID, $this->serverUrl, $this->compatabilityLevel, $this->siteID, 'GetOrderTransactions');
        $requestXmlBody = ' <?xml version="1.0" encoding="utf-8"?>
								<GetOrderTransactionsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
								<RequesterCredentials>
									<eBayAuthToken>' . $this->token . '</eBayAuthToken>
								</RequesterCredentials>
								<DetailLevel>ReturnAll</DetailLevel>
								<OutputSelector>OrderArray.Order.TransactionArray.Transaction.Buyer.BuyerInfo.ShippingAddress</OutputSelector>
								<IncludeFinalValueFee>true</IncludeFinalValueFee>
								<OrderRole>Seller</OrderRole>
								<OrderStatus>Completed</OrderStatus>
								<OrderIDArray>
									<OrderID>' . $orderid . '</OrderID>
								</OrderIDArray>
							</GetOrderTransactionsRequest>';
        $responseXml = $handle->sendHttpRequest($requestXmlBody);
        $responseDoc = new DomDocument();
        $responseDoc->loadXML($responseXml);
        return $responseDoc->getElementsByTagName('ShippingAddress')->item(0);
    }
Пример #5
0
    public function sendEbayCsMail($itemId, $buyerId, $sendContent, $subject)
    {
        include_once WEB_PATH . 'lib/ebaylibrary/eBaySession.php';
        global $devID, $appID, $certID, $serverUrl, $siteID, $compatabilityLevel, $userToken;
        $verb = 'AddMemberMessageAAQToPartner';
        $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
        $requestXML = <<<EOF
        <?xml version="1.0" encoding="utf-8"?>
        <AddMemberMessageAAQToPartnerRequest xmlns="urn:ebay:apis:eBLBaseComponents">
          <RequesterCredentials>
            <eBayAuthToken>{$userToken}</eBayAuthToken>
          </RequesterCredentials>
          <ItemID>{$itemId}</ItemID>
          <MemberMessage>
            <Subject>{$subject}</Subject>
            <Body>{$sendContent}</Body>
            <EmailCopyToSender>true</EmailCopyToSender>
            <QuestionType>General</QuestionType>
            <RecipientID>{$buyerId}</RecipientID>
          </MemberMessage>
        </AddMemberMessageAAQToPartnerRequest>
EOF;
        $responseXml = $session->sendHttpRequest($requestXML);
        if (stristr($responseXml, 'HTTP 404') || $responseXml == '' || $responseXml === FALSE) {
            self::$errMsg = __METHOD__ . '发送请求失败! in line ' . __LINE__;
            return FALSE;
        }
        $data = XML_unserialize($responseXml);
        $ack = $data['AddMemberMessageAAQToPartnerResponse'];
        $ack = $ack['Ack'];
        if ($ack == 'Success') {
            return TRUE;
        } else {
            $err = $data['AddMemberMessageAAQToPartnerResponse']['Errors']['LongMessage'];
            self::$errMsg = '处理失败 ::ERR INFO ==> ' . $err;
            return FALSE;
        }
    }
Пример #6
0
 function __construct($username, $theID)
 {
     global $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID;
     // defined in keys.php
     $verb = 'FetchToken';
     ///Build the request Xml string
     $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
     $requestXmlBody .= '<FetchTokenRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
     // $requestXmlBody .= "<RequesterCredentials><Username>$username</Username></RequesterCredentials>";
     $requestXmlBody .= "<SessionID>{$theID}</SessionID>";
     $requestXmlBody .= '</FetchTokenRequest>';
     //Create a new eBay session with all details pulled in from included keys.php
     $session = new eBaySession($devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
     //send the request and get response
     $responseXml = $session->sendHttpRequest($requestXmlBody);
     if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
         die('<P>Error sending request');
     }
     $resp = simplexml_load_string($responseXml);
     $this->token = (string) $resp->eBayAuthToken;
     // need to cast to string (not SimpleXML element) to persist in SESSION
     $this->expiration = $resp->HardExpirationTime;
 }
Пример #7
0
function GetListByItemID($token, $itemid, $account)
{
    global $dbcon, $devID, $appID, $certID, $serverUrl, $siteID, $detailLevel, $compatabilityLevel;
    $user = '******';
    $verb = 'GetItem';
    $requestXmlBody = '<?xml version="1.0" encoding="utf-8"?>
								<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
								<RequesterCredentials>
									<eBayAuthToken>' . $token . '</eBayAuthToken>
								</RequesterCredentials>
								<ItemID>' . $itemid . '</ItemID>
								<WarningLevel>High</WarningLevel>
								</GetItemRequest>';
    $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
    $responseXml = $session->sendHttpRequest($requestXmlBody);
    if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
        return 'id not found';
    }
    $responseDoc = new DomDocument();
    $responseDoc->loadXML($responseXml);
    $data = XML_unserialize($responseXml);
    //print_r($data);
    $Ack = $data['GetItemResponse']['Ack'];
    if ($Ack == 'Success') {
        $result = $data['GetItemResponse']['Item'];
        $ViewItemURL = $result['ListingDetails']['ViewItemURL'];
        $main_QuantitySold = $result['SellingStatus']['QuantitySold'];
        $main_Quantity = $result['Quantity'];
        $Title = $result['Title'];
        $main_SKU = $result['SKU'];
        $ListingType = $result['ListingType'];
        $StartPrice = $result['StartPrice'];
        $main_QuantityAvailable = $main_Quantity - $main_QuantitySold;
        $StartPricecurrencyID = $result['BuyItNowPrice attr']['currencyID'];
        $ShippingCost = $result['ShippingDetails']['ShippingServiceOptions']['ShippingServiceCost'];
        $Site = $result['Site'];
        echo '运费:' . $ShippingCost . "\n";
        $pos = strpos($main_SKU, ':');
        if ($pos === false) {
            $realsku = str_pad($main_SKU, 3, '0', STR_PAD_LEFT);
        } else {
            $realsku = substr($main_SKU, 0, $pos);
        }
        $sql = "select id from ebay_list where ItemID='{$itemid}' and ebay_account ='{$account}' ";
        $sql = $dbcon->execute($sql);
        $sql = $dbcon->getResultArray($sql);
        if (count($sql) == 1) {
            $del = "delete from ebay_list where ItemID='{$itemid}'";
            $dbcon->execute($del);
        }
        $main_list = "insert into ebay_list(status,ItemID,ViewItemURL,QuantitySold,Quantity,Title,SKU,realSKU,ListingType,StartPrice,ebay_account,ebay_user,QuantityAvailable,StartPricecurrencyID,ShippingCost,Site) value('0','{$itemid}','{$ViewItemURL}','{$main_QuantitySold}','{$main_Quantity}','{$Title}','{$main_SKU}','{$realsku}','{$ListingType}','{$StartPrice}','{$account}','{$user}','{$main_QuantityAvailable}','{$StartPricecurrencyID}','{$ShippingCost}','{$Site}')";
        //echo $main_list."\n";
        if ($dbcon->execute($main_list)) {
            echo $itemid . '同步成功' . "\n";
            $Variations = $result['Variations']['Variation'];
            if ($Variations != '') {
                for ($i = 0; $i < count($Variations); $i++) {
                    $SKU = $Variations[$i]['SKU'];
                    $Quantity = $Variations[$i]['Quantity'];
                    $StartPrice = $Variations[$i]['StartPrice'];
                    $QuantitySold = $Variations[$i]['SellingStatus']['QuantitySold'];
                    $tjstr = '';
                    $VariationSpecifics = $Variations[$i]['VariationSpecifics'];
                    if ($VariationSpecifics != '') {
                        $NameValueList = $Variations[$i]['VariationSpecifics']['NameValueList']['Name'];
                        if ($NameValueList != '') {
                            $NameValueList = array();
                            $NameValueList[0] = $Variations[$i]['VariationSpecifics']['NameValueList'];
                        }
                        for ($n = 0; $n < count($NameValueList); $n++) {
                            $Nname = $NameValueList[$n]['Name'];
                            $Nvalue = $NameValueList[$n]['Value'];
                            $tjstr .= $Nname . '**' . $Nvalue . '++';
                        }
                        $tjstr = mysql_real_escape_string($tjstr);
                    }
                    $QuantityAvailable = $Quantity - $QuantitySold;
                    $sel = "select id from ebay_listvariations where ebay_account='{$account}' and itemid='{$itemid}' and SKU='{$SKU}' ";
                    $sel = $dbcon->execute($sel);
                    $sel = $dbcon->getResultArray($sel);
                    if (count($sel) != 0) {
                        $d_del = "delete from ebay_listvariations where itemid='{$itemid}'";
                        $dbcon->execute($d_del);
                    }
                    $detail_list = "insert into ebay_listvariations(SKU,Quantity,StartPrice,itemid,ebay_account,QuantitySold,QuantityAvailable,VariationSpecifics) values('{$SKU}','{$Quantity}','{$StartPrice}','{$itemid}','{$account}','{$QuantitySold}','{$QuantityAvailable}','{$tjstr}')";
                    //echo $detail_list."\n";
                    $dbcon->execute($detail_list);
                }
            }
        } else {
            echo $itemid . '同步失败<br>';
        }
    }
}
Пример #8
0
 ///Build the request Xml string
 $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
 $requestXmlBody .= '<ReviseCheckoutStatusRequest   xmlns="urn:ebay:apis:eBLBaseComponents">';
 $requestXmlBody .= "<RequesterCredentials><eBayAuthToken>{$userToken}</eBayAuthToken></RequesterCredentials>";
 $requestXmlBody .= "<DetailLevel>{$detailLevel}</DetailLevel>";
 $requestXmlBody .= "<ErrorLanguage>{$errorLanguage}</ErrorLanguage>";
 $requestXmlBody .= "<Version>{$compatabilityLevel}</Version>";
 $requestXmlBody .= "<AdjustmentAmount>{$adjustmentAmount}</AdjustmentAmount> ";
 $requestXmlBody .= "<AmountPaid currencyID =\"USD\">{$amountPaid}</AmountPaid> ";
 $requestXmlBody .= "<OrderLineItemID>{$orderLineItemID}</OrderLineItemID>";
 $requestXmlBody .= "<OrderID>{$orderLineItemID}</OrderID>";
 $requestXmlBody .= "<PaymentMethodUsed>MOCC</PaymentMethodUsed>";
 $requestXmlBody .= "<CheckoutStatus>Complete</CheckoutStatus> ";
 $requestXmlBody .= '</ReviseCheckoutStatusRequest>';
 //Create a new eBay session with all details pulled in from included keys.php
 $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
 //send the request and get response
 $responseXml = $session->sendHttpRequest($requestXmlBody);
 if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
     die('<P>Error sending request');
 }
 //Xml string is parsed and creates a DOM Document object
 $responseDoc = new DomDocument();
 $responseDoc->loadXML($responseXml);
 //get any error nodes
 $errors = $responseDoc->getElementsByTagName('Errors');
 //if there are error nodes
 if ($errors->length > 0) {
     echo '<P><B>eBay returned the following error(s):</B>';
     //display each error
     //Get error code, ShortMesaage and LongMessage
Пример #9
0
 public function __construct()
 {
     parent::__construct();
 }
Пример #10
0
 public static function getItemSpecifics($categoryID)
 {
     if (!self::checkItemSpecificsEnabled($categoryID)) {
         return array();
     }
     require_once './config.php';
     require_once './eBaySession.php';
     $callName = 'GetCategorySpecifics';
     $requestXMLBody = self::getItemSpecificsXMLBody($appToken, $categoryID);
     $session = new eBaySession($devID, $appID, $certificateID, $serverUrl, $compatabilityLevel, $siteID, $callName);
     $respondXML = $session->sendHttpRequest($requestXMLBody);
     $resp = simplexml_load_string($respondXML);
     return self::makeItemSpecificsNameAndValue($resp);
 }
Пример #11
0
    public function markAsRead($messageid, $type = 'Read', $flag = '')
    {
        //return TRUE;
        $msg_obj = new messageModel();
        $msginof = $msg_obj->getMessageInfo(array($messageid));
        $verb = 'ReviseMyMessages';
        global $devID, $appID, $certID, $serverUrl, $siteID, $compatabilityLevel, $mctime, $userToken;
        $xmlRequest = '<?xml version="1.0" encoding="utf-8"?>
			<ReviseMyMessagesRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  			<WarningLevel>High</WarningLevel>
  			<MessageIDs>
    		<MessageID>' . $msginof[0]['message_id'] . '</MessageID>
  			</MessageIDs>
        ';
        $xmlRequest .= '<Read>true</Read>';
        $xmlRequest .= '
  			<RequesterCredentials>
    		<eBayAuthToken>' . $userToken . '</eBayAuthToken>
  			</RequesterCredentials>
  			<WarningLevel>High</WarningLevel>
			</ReviseMyMessagesRequest>
			';
        $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
        $responseXml = $session->sendHttpRequest($xmlRequest);
        //echo $responseXml;exit;
        if (stristr($responseXml, 'HTTP 404') || $responseXml == '' || $responseXml === FALSE) {
            self::$errCode = 9001;
            self::$sender = $msginof[0]['replyuser_id'];
            self::$errMsg = __METHOD__ . '发送请求失败! in line ' . __LINE__;
            self::$sendMsg = __METHOD__ . '发送请求失败! in line ' . __LINE__;
            return FALSE;
        }
        $data = XML_unserialize($responseXml);
        //print_r($data);
        $ack = $data['ReviseMyMessagesResponse'];
        $ack = $ack['Ack'];
        if ($ack == 'Success') {
            return TRUE;
        } else {
            self::$sender = $msginof[0]['replyuser_id'];
            self::$errMsg = $xmlRequest . '-----' . $responseXml . __LINE__ . "\n";
            $obj_return = simplexml_load_string($responseXml);
            if ($obj_return && isset($obj_return->Errors->LongMessage)) {
                self::$sendMsg = 'MSGID:' . $msginof[0]['message_id'] . '发送人:' . $msginof[0]['sendid'] . ' ++++ 原因 :' . $obj_return->Errors->LongMessage;
            } else {
                self::$sendMsg = 'MSGID:' . $msginof[0]['message_id'] . '发送人:' . $msginof[0]['sendid'] . ' ++++ ' . '原因未知';
            }
            return FALSE;
        }
    }
Пример #12
0
function OnlineStoreEbay_adminImportOrders()
{
    require_once 'eBaySession.php';
    error_reporting(E_ALL);
    $rs = dbAll('select * from online_store_vars where name like "ebay%"');
    $vs = array();
    foreach ($rs as $r) {
        $vs[$r['name']] = $r['val'];
    }
    $production = (int) $vs['ebay_status'];
    if ($production) {
        $devID = $vs['ebay_devid'];
        $appID = $vs['ebay_appid'];
        $certID = $vs['ebay_certid'];
        $serverUrl = 'https://api.ebay.com/ws/api.dll';
        // server URL different for prod and sandbox
        $userToken = $vs['ebay_usertoken'];
    } else {
        $devID = $vs['ebay_sandbox_devid'];
        $appID = $vs['ebay_sandbox_appid'];
        $certID = $vs['ebay_sandbox_certid'];
        $serverUrl = 'https://api.sandbox.ebay.com/ws/api.dll';
        $userToken = $vs['ebay_sandbox_usertoken'];
    }
    $compatabilityLevel = 827;
    // eBay API version
    $siteToUseID = 205;
    $sess = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteToUseID, 'GetOrders');
    $xml = '<?xml version="1.0" encoding="utf-8"?>' . '<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">' . '	<RequesterCredentials>' . '		<eBayAuthToken>' . $userToken . '</eBayAuthToken>' . '	</RequesterCredentials>' . '	<NumberOfDays>10</NumberOfDays>' . '	<OrderRole>Seller</OrderRole>' . '	<OrderStatus>Completed</OrderStatus>' . '	<DetailLevel>ReturnAll</DetailLevel>' . '	<SortingOrder>Descending</SortingOrder>' . '	<WarningLevel>High</WarningLevel>' . '</GetOrdersRequest>';
    $xmlstr = $sess->sendHttpRequest($xml);
    $reply = new SimpleXMLElement($xmlstr);
    if (isset($reply->Errors)) {
        return array('sent' => $xml, 'reply' => new SimpleXMLElement($xmlstr), 'errors' => $reply->Errors);
    }
    $imported = 0;
    foreach ($reply->OrderArray->Order as $order) {
        $order = json_decode(json_encode($order));
        $ebayOrderId = $order->OrderID;
        $r = dbOne('select id from online_store_orders where ebayOrderId="' . $ebayOrderId . '"' . ' limit 1', 'id');
        if ($r) {
            continue;
        }
        $address = $order->ShippingAddress;
        if ($address->PostalCode == '') {
            $address->PostalCode = 'na';
        }
        $form_vals = array('FirstName' => preg_replace('/ .*/', '', $address->Name), 'Surname' => preg_replace('/.*? /', '', $address->Name), 'Phone' => $address->Phone, 'Email' => '*****@*****.**', 'Street' => $address->Street1, 'Street2' => $address->Street2, 'Town' => $address->CityName, 'County' => $address->StateOrProvince, 'PostCode' => $address->PostalCode, 'Country' => $address->CountryName, 'CountryCode' => $address->Country);
        $form_vals = json_encode($form_vals);
        $total = (double) $order->Total;
        $date_created = date('Y-m-d h:i:s', strtotime($order->CreatedTime));
        $transactions = array();
        $tArr = $order->TransactionArray->Transaction;
        if (!is_array($tArr)) {
            $transactions = array($tArr);
        } else {
            $transactions = $tArr;
        }
        $items = array();
        foreach ($transactions as $transaction) {
            $item = $transaction->Item;
            if (isset($item->ApplicationData)) {
                $appData = json_decode(htmlspecialchars_decode($item->ApplicationData));
                $itemId = $appData->productId;
            } else {
                $itemId = dbOne('select id from products where link="' . addslashes($item->Title) . '"', 'id');
            }
            $key = 'products_' . $itemId;
            if (!isset($items[$key])) {
                $items[$key] = array();
                $r = dbRow('select * from products where id=' . $itemId . ' limit 1');
                $items[$key] = array('short_desc' => $r['name'], 'id' => $itemId, 'amt' => 0);
            }
            $items[$key]['amt'] += $transaction->QuantityPurchased;
        }
        $jitems = json_encode($items);
        // { create the order entry
        dbQuery('insert into online_store_orders set total="' . $total . '"' . ', items="' . addslashes($jitems) . '"' . ', ebayOrderId="' . $ebayOrderId . '"' . ', form_vals="' . addslashes($form_vals) . '"' . ', date_created="' . addslashes($date_created) . '"' . ', status=1');
        $id = dbLastInsertId();
        // }
        dbQuery('update online_store_orders set invoice_num=id where id=' . $id);
        Core_cacheClear('online_store_orders');
        OnlineStore_updateProductSales($id, $items, $date_created);
        $imported++;
    }
    return array('imported' => $imported, 'reply' => new SimpleXMLElement($xmlstr));
}
Пример #13
0
    public function GetItem($itemId)
    {
        $session = new eBaySession('GetItem', $this);
        //Build the request Xml string
        /*$requestXmlBody = '<?xml version="1.0" encoding="utf-8"?>
        							<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
        							  <ItemID>'.$itemId.'</ItemID>
        							</GetSingleItemRequest>';
        		*/
        $requestXmlBody = '<?xml version="1.0" encoding="utf-8"?>
								<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
								  <RequesterCredentials>
									<eBayAuthToken>' . $_SESSION['userToken'] . '</eBayAuthToken>
								  </RequesterCredentials>
								  <Version>' . $this->compatabilityLevel . '</Version>
								  <IncludeItemSpecifics>true</IncludeItemSpecifics>
								  <IncludeTaxTable>true</IncludeTaxTable>
								  <IncludeWatchCount>true</IncludeWatchCount>
								  <ItemID>' . $itemId . '</ItemID>
								  <DetailLevel>ItemReturnDescription</DetailLevel>
								    <IncludeSelector>Description,ItemSpecifics</IncludeSelector>

								</GetItemRequest>';
        //Create a new eBay session with all details pulled in from included keys.php
        $responseXml = $session->sendHttpRequest($requestXmlBody);
        return $responseXml;
    }
Пример #14
0
 if (@(!$_SESSION['sid'])) {
     // @ to suppress warnings
     $_SESSION['sid'] = md5(uniqid(rand(), true));
     // secret ID for FetchToken request
 }
 // Get session ID for the Auth & Auth, save it in session variable for subsequent FetchToken
 // call in Token.php.
 $verb1 = 'GetSessionID';
 ///Build the request Xml string
 $requestBody1 = '<?xml version="1.0" encoding="utf-8" ?>';
 $requestBody1 .= '<GetSessionIDRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
 $requestBody1 .= "<Version>{$compatabilityLevel}</Version>";
 $requestBody1 .= "<RuName>{$runame}</RuName>";
 $requestBody1 .= '</GetSessionIDRequest>';
 //Create a new eBay session with all details pulled in from included keys.php
 $sessN = new eBaySession($devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb1);
 //send the request and get response
 $responseBody1 = $sessN->sendHttpRequest($requestBody1);
 if (stristr($responseBody1, 'HTTP 404') || $responseBody1 == '') {
     die('<P>Error sending request');
 }
 $resp1 = simplexml_load_string($responseBody1);
 $_SESSION['ebSession'] = (string) $resp1->SessionID;
 $sesId = urlencode($_SESSION['ebSession']);
 $results .= "<form\tname=\"form_auth\" method=\"post\" action=\"./Login.php\" >";
 $results .= "<table><tr>\n<td>eBay User ID:</td> <td align=\"left\">" . "<input\ttype=\"text\" name=\"username\" size=\"50\" maxlength=\"20\"></td>\n";
 // loginURL and runame in next line comes from the required keys.php file
 $results .= "<td><INPUT TYPE=\"submit\" NAME=AUTHORIZE VALUE=\"Launch Auth & Auth\" " . "onclick=\"window.open('{$loginURL}?SignIn&runame={$runame}&SessID={$sesId}');\">\n";
 $results .= "</td></tr></table>\n";
 // use hidden field to retain fact that we're waiting on outcome of Auth and Auth call
 $results .= "<input type=\"hidden\" name=\"loginPending\" value=\"true\">\n";
Пример #15
0
    public function verifyAddItem($img)
    {
        $session = new eBaySession('VerifyAddItem', $this);
        $description = "test";
        $title = "TITLE";
        $conditionId = 1000;
        $site = "0";
        // US
        $sku = "x2222";
        $category = "171485";
        $price = 14.0;
        $quantity = 2;
        $listingType = "FixedPriceItem";
        $location = "US";
        $dispatchTime = 2;
        $listingDuration = "Days_10";
        $xml = '<?xml version="1.0" encoding="utf-8"?>
				<VerifyAddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
				<RequesterCredentials>
                                <eBayAuthToken>' . $this->userToken . '</eBayAuthToken>
                </RequesterCredentials>
				  <Item> 
						 <Description>' . $description . '</Description>
						 <Title>' . $title . '</Title>
						 <SKU>' . $sku . '</SKU>
						 <ConditionID>' . $conditionId . '</ConditionID>
						 <PrimaryCategory><CategoryID>' . $category . '</CategoryID></PrimaryCategory>
						 <StartPrice>' . $price . '</StartPrice>
						 <Currency>USD</Currency>
						 <Country>US</Country>
						 <Quantity>' . $quantity . '</Quantity>				    
						 <ListingType>' . $listingType . '</ListingType>					
						 <ListingDuration>' . $listingDuration . '</ListingDuration>
						 <Location>' . $location . '</Location>
						 <ShippingDetails>
						 	  <ShippingType>Flat</ShippingType>
							  <ShippingServiceOptions>
								<ShippingServicePriority>1</ShippingServicePriority>
								<ShippingService>USPSMedia</ShippingService>
								<ShippingServiceCost>2.50</ShippingServiceCost>
							  </ShippingServiceOptions>			 
						 </ShippingDetails>
						 <PictureDetails>
						   <PictureURL>' . $img . '</PictureURL>
						 </PictureDetails>
						 <ReturnPolicy>
						 	<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
					        <RefundOption>MoneyBack</RefundOption>
					        <ReturnsWithinOption>Days_30</ReturnsWithinOption>
							<Description>If you are not satisfied, return the book for refund.</Description>
 					        <ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
						 </ReturnPolicy>
						 <DispatchTimeMax>' . $dispatchTime . '</DispatchTimeMax>
							<PaymentMethods>PayPal</PaymentMethods>
							<PayPalEmailAddress>nikatlas@gmail.com</PayPalEmailAddress>
					</Item>
				  </VerifyAddItemRequest>
				';
        $responseXml = $session->sendHttpRequest($xml);
        return $responseXml;
    }
Пример #16
0
function GetSellerEventsv2($account, $token, $start, $end)
{
    $verb = 'GetSellerEvents';
    global $devID, $appID, $certID, $serverUrl, $siteID, $detailLevel, $compatabilityLevel, $dbcon, $user;
    $currentpage = 1;
    $xmlRequest = '<?xml version="1.0" encoding="utf-8"?>
			<GetSellerEventsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
			<RequesterCredentials>
			<eBayAuthToken>' . $token . '</eBayAuthToken>
			</RequesterCredentials>
			<HideVariations>false</HideVariations>
			<ModTimeFrom>' . $start . '</ModTimeFrom>
			<DetailLevel>ReturnAll</DetailLevel>
			</GetSellerEventsRequest>';
    $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
    $responseXml = $session->sendHttpRequest($xmlRequest);
    if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
        return 'id not found';
    }
    $data = XML_unserialize($responseXml);
    if ($data['GetSellerEventsResponse']['ItemArray'] == '') {
        return;
    }
    $totalitems = @$data['GetSellerEventsResponse']['ItemArray']['Item'];
    if (@$data['GetSellerEventsResponse']['ItemArray']['Item']['ItemID'] != '') {
        $totalitems = array();
        $totalitems[0] = $data['GetSellerEventsResponse']['ItemArray']['Item'];
    }
    for ($i = 0; $i < count($totalitems); $i++) {
        $ItemID = $totalitems[$i]['ItemID'];
        $ViewItemURL = $totalitems[$i]['ListingDetails']['ViewItemURL'];
        $ListingType = $totalitems[$i]['ListingType'];
        $Quantity = $totalitems[$i]['Quantity'];
        $QuantitySold = $totalitems[$i]['SellingStatus']['QuantitySold'];
        $ListingStatus = $totalitems[$i]['SellingStatus']['ListingStatus'];
        $StartPrice = $totalitems[$i]['SellingStatus']['CurrentPrice'];
        $StartPricecurrencyID = $totalitems[$i]['CurrentPrice attr']['currencyID'];
        $Site = $totalitems[$i]['Site'];
        $SiteIDS = getEbaysiteid($Site);
        $Title = $totalitems[$i]['Title'];
        $SKU = $totalitems[$i]['SKU'];
        $QuantityAvailable = $Quantity - $QuantitySold;
        $ss = "select * from ebay_list where ebay_account ='{$account}' and ebay_user='******' and ItemID='{$ItemID}' ";
        $ss = $dbcon->execute($ss);
        $ss = $dbcon->getResultArray($ss);
        /* 更新现有的Listing 数量 */
        if (count($ss) >= 1) {
            if ($ListingStatus != 'Active') {
                $vv = " update ebay_list set status ='1' where ebay_account ='{$account}' and ebay_user='******' and ItemID='{$ItemID}' ";
                $dbcon->execute($vv);
            } else {
                $QuantityAvailableold = $ss[0]['QuantityAvailable'];
                $track_stock = $ss[0]['track_stock'];
                // 是否启用跟踪库存的
                $track_price = $ss[0]['track_price'];
                // 是否启用跟踪价格的
                $id = $ss[0]['id'];
                //
                $addprice = $ss[0]['addprice'];
                //
                $jianprice = $ss[0]['jianprice'];
                //
                $hightprice = $ss[0]['hightprice'];
                $lawprice = $ss[0]['lawprice'];
                $newolqty = $QuantityAvailableold - $QuantityAvailable;
                if ($newolqty > 0 && $track_stock == 0 && $totalitems[$i]['Variations']['Variation'] == '') {
                    $runstatus = ModbyItemID($QuantityAvailable + $newolqty, $token, $ItemID, $account, $SiteIDS);
                    if ($runstatus == '1') {
                        $QuantityAvailable = $QuantityAvailable + $newolqty;
                    }
                    echo $i . ': RUN: TO EBAY: ' . $ItemID . "\n\r";
                } else {
                    echo $i . ': RUN: NO EBAY: ' . $ItemID . "\n\r";
                }
                $vv = "update ebay_list set QuantityAvailable = '{$QuantityAvailable}',StartPrice='{$StartPrice}',QuantitySold='{$QuantitySold}',Site\t='{$Site}' where id ='{$id}' ";
                $dbcon->execute($vv);
                /* 开始检查是否有多属性物品 */
                $Variations = $totalitems[$i]['Variations']['Variation'];
                if ($Variations != '') {
                    if ($totalitems[$i]['Variations']['Variation']['StartPrice'] != '') {
                        $Variations = array();
                        $Variations[0] = $totalitems[$i]['Variations']['Variation'];
                    }
                    for ($j = 0; $j < count($Variations); $j++) {
                        $SKU = $Variations[$j]['SKU'];
                        $Quantity = $Variations[$j]['Quantity'];
                        $StartPrice = $Variations[$j]['StartPrice'];
                        $QuantitySold = $Variations[$j]['SellingStatus']['QuantitySold'];
                        $tjstr = '';
                        $VariationSpecifics = $Variations[$j]['VariationSpecifics'];
                        if ($VariationSpecifics != '') {
                            $NameValueList = $Variations[$j]['VariationSpecifics']['NameValueList']['Name'];
                            if ($NameValueList != '') {
                                $NameValueList = array();
                                $NameValueList[0] = $Variations[$j]['VariationSpecifics']['NameValueList'];
                            } else {
                                $NameValueList = $Variations[$j]['VariationSpecifics']['NameValueList'];
                            }
                            for ($n = 0; $n < count($NameValueList); $n++) {
                                $Nname = $NameValueList[$n]['Name'];
                                $Nvalue = $NameValueList[$n]['Value'];
                                $tjstr .= $Nname . '**' . $Nvalue . '++';
                            }
                            $tjstr = mysql_escape_string($tjstr);
                        }
                        $QuantityAvailable = $Quantity - $QuantitySold;
                        if ($SKU != '') {
                            $ss = "select * from ebay_listvariations where ebay_account='{$account}' and itemid='{$ItemID}' and   SKU='{$SKU}' ";
                        } else {
                            $ss = "select * from ebay_listvariations where ebay_account='{$account}' and itemid='{$ItemID}' and   VariationSpecifics='{$tjstr}' ";
                        }
                        $ss = $dbcon->execute($ss);
                        $ss = $dbcon->getResultArray($ss);
                        if (count($ss) > 0) {
                            $VariationSpecifics = $ss[0]['VariationSpecifics'];
                            $newolqty = $ss[0]['QuantityAvailable'];
                            $newolqty1 = $QuantityAvailable;
                            // 现在同步进来的数量
                            $nowqty = $newolqty - $newolqty1;
                            // 共出几个
                            echo 'OLD=' . $newolqty . ' NEW= ' . $newolqty1 . ' changeqty= ' . $nowqty . ' Item  ID:' . $ItemID . '<br>';
                            if ($nowqty > 0 && $track_stock == 0) {
                                $chageqty = $nowqty + $newolqty1;
                                $runstatus = ModbyItemIDsku($chageqty, $token, $ItemID, $account, $SKU, $VariationSpecifics, $SiteIDS);
                                if ($runstatus == 1) {
                                    $QuantityAvailable = $chageqty;
                                }
                            }
                            $rr = "update ebay_listvariations set Quantity ='{$Quantity}' , QuantitySold ='{$QuantitySold}' , StartPrice='{$StartPrice}',QuantityAvailable='{$QuantityAvailable}',VariationSpecifics='{$tjstr}' where ebay_account ='{$account}' and ItemID ='{$ItemID}' and SKU='{$SKU}' ";
                            $dbcon->execute($rr);
                        }
                    }
                }
            }
        } else {
            echo '<br>not found';
        }
    }
}
$firstPart = '';
$firstPart .= "--" . $boundary . $CRLF;
$firstPart .= 'Content-Disposition: form-data; name="XML Payload"' . $CRLF;
$firstPart .= 'Content-Type: text/xml;charset=utf-8' . $CRLF . $CRLF;
$firstPart .= $xmlReq;
$firstPart .= $CRLF;
$secondPart .= "--" . $boundary . $CRLF;
$secondPart .= 'Content-Disposition: form-data; name="dummy"; filename="dummy"' . $CRLF;
$secondPart .= "Content-Transfer-Encoding: binary" . $CRLF;
$secondPart .= "Content-Type: application/octet-stream" . $CRLF . $CRLF;
$secondPart .= $multiPartImageData;
$secondPart .= $CRLF;
$secondPart .= "--" . $boundary . "--" . $CRLF;
$fullPost = $firstPart . $secondPart;
// Create a new eBay session (defined below)
$session = new eBaySession($userToken, $devID, $appID, $certID, false, $version, $siteID, $verb, $boundary);
$respXmlStr = $session->sendHttpRequest($fullPost);
// send multi-part request and get string XML response
if (stristr($respXmlStr, 'HTTP 404') || $respXmlStr == '') {
    die('<P>Error sending request');
}
$respXmlObj = simplexml_load_string($respXmlStr);
// create SimpleXML object from string for easier parsing
// need SimpleXML library loaded for this
/* Returned XML is of form 
     <?xml version="1.0" encoding="utf-8"?>
     <UploadSiteHostedPicturesResponse xmlns="urn:ebay:apis:eBLBaseComponents">
       <Timestamp>2007-06-19T16:53:50.370Z</Timestamp>
       <Ack>Success</Ack>
       <Version>517</Version>
       <Build>e517_core_Bundled_4784308_R1</Build>
Пример #18
0
 public function GetMySellings()
 {
     $verb = 'GetMyeBaySelling';
     $compatibilityLevel = 505;
     $session = new eBaySession($this->userToken, $this->devID, $this->appID, $this->certID, $this->serverUrl, $compatibilityLevel, 0, $verb);
     $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
     $requestXmlBody .= '<GetMyeBaySellingRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
     $requestXmlBody .= "<RequesterCredentials><eBayAuthToken>{$this->userToken}</eBayAuthToken></RequesterCredentials>";
     $requestXmlBody .= "<Version>{$compatibilityLevel}</Version>";
     $requestXmlBody .= "<ActiveList><Sort>TimeLeft</Sort><Pagination><EntriesPerPage>200</EntriesPerPage><PageNumber>2</PageNumber></Pagination></ActiveList>";
     $requestXmlBody .= '</GetMyeBaySellingRequest>';
     $responseXml = $session->sendHttpRequest($requestXmlBody);
     if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
         die('<P>Error sending request');
     }
     //Xml string is parsed and creates a DOM Document object
     $responseDoc = new DomDocument();
     $responseDoc->loadXML($responseXml);
     //get any error nodes
     $errors = $responseDoc->getElementsByTagName('Errors');
     $response = simplexml_import_dom($responseDoc);
     //if there are error nodes
     if ($errors->length > 0) {
         echo '<P><B>eBay returned the following error(s):</B>';
         //display each error
         //Get error code, ShortMesaage and LongMessage
         $code = $errors->item(0)->getElementsByTagName('ErrorCode');
         $shortMsg = $errors->item(0)->getElementsByTagName('ShortMessage');
         $longMsg = $errors->item(0)->getElementsByTagName('LongMessage');
         //Display code and shortmessage
         echo '<P>', $code->item(0)->nodeValue, ' : ', str_replace(">", "&gt;", str_replace("<", "&lt;", $shortMsg->item(0)->nodeValue));
         //if there is a long message (ie ErrorLevel=1), display it
         if (count($longMsg) > 0) {
             echo '<BR>', str_replace(">", "&gt;", str_replace("<", "&lt;", $longMsg->item(0)->nodeValue));
         }
     }
     $result['itemArray'] = $response->ActiveList->ItemArray->Item;
     $this->load->view('view_my_sellings', $result);
 }
Пример #19
0
/**	getOnlineTreeVersion
	Returns the Version number of the Category tree that is currently available online
*/
function getOnlineTreeVersion($devID, $appID, $certID, $compatabilityLevel, $siteID, $userToken, $serverUrl)
{
    //Build the request Xml string
    $requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
    $requestXmlBody .= '<GetCategoriesRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
    $requestXmlBody .= "<RequesterCredentials><eBayAuthToken>{$userToken}</eBayAuthToken></RequesterCredentials>";
    $requestXmlBody .= "<Item><Site>{$siteID}</Site></Item>";
    $requestXmlBody .= "<ViewAllNodes>0</ViewAllNodes>";
    $requestXmlBody .= '</GetCategoriesRequest>';
    //Create a new eBay session with all details pulled in from included keys.php
    $session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, 'GetCategories');
    //send the request
    $responseXml = $session->sendHttpRequest($requestXmlBody);
    if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
        die('<P>Error sending request');
    }
    //Xml string is parsed and creates a DOM Document object
    $responseDoc = new DomDocument();
    $responseDoc->loadXML($responseXml);
    //get the version name
    $version = $responseDoc->getElementsByTagName('CategoryVersion');
    //return the version
    return $version->item(0)->nodeValue;
}
Пример #20
0
    function act_feedbackChangeMutilMessage()
    {
        include WEB_PATH . "lib/feedback/ebaylibrary/ebay_config.php";
        //print_r($_POST);//exit;
        $bills = isset($_POST['bill']) ? $_POST['bill'] : '';
        $content = isset($_POST['content']) ? $_POST['content'] : '';
        $content = htmlspecialchars($content);
        $content = str_replace("\\", "", $content);
        if ($bills == '' || $content == '') {
            self::$errCode = '001';
            self::$errMsg = "参数错误!";
            return false;
        }
        $accountArr = array();
        foreach ($bills as $bill) {
            $accountArr[] = $bill['account'];
        }
        $accountArr = array_unique($accountArr);
        $accountStr = implode("','", $accountArr);
        $accAct = new AccountAct();
        $accountInfo = $accAct->act_getAccountList('account,token', "where account in ('{$accountStr}') and is_delete = 0");
        $accountTokens = array();
        foreach ($accountInfo as $v) {
            $accountTokens[$v['account']] = $v['token'];
        }
        foreach ($bills as &$bill) {
            $bill['token'] = $accountTokens[$bill['account']];
            $where = " where account = '{$bill['account']}' and CommentingUser = '******'ebayUserId']}' limit 1";
            $lists = EbayFeedbackModel::getOrderList('itemID', $where);
            $bill['itemID'] = $lists[0]['itemID'];
        }
        //print_r($bills);exit;
        $verb = 'AddMemberMessageAAQToPartner';
        foreach ($bills as $bil) {
            //$feedbackid	= $bill['feedbackID'];
            $userid = $bil['ebayUserId'];
            $itemid = $bil['itemID'];
            $account = $bil['account'];
            $token = $bil['token'];
            $requestXmlBody = '<?xml version="1.0" encoding="utf-8"?>
			<AddMemberMessageAAQToPartnerRequest xmlns="urn:ebay:apis:eBLBaseComponents">
				<RequesterCredentials>
					<eBayAuthToken>' . $token . '</eBayAuthToken>
				</RequesterCredentials>
				<ItemID>' . $itemid . '</ItemID>
				<MemberMessage>
					<EmailCopyToSender>true</EmailCopyToSender>
					<Body>' . $content . '</Body>
					<QuestionType>General</QuestionType>
					<RecipientID>' . $userid . '</RecipientID>
				</MemberMessage>
			</AddMemberMessageAAQToPartnerRequest>';
            $session = new eBaySession($token, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $verb);
            //print_r($session);
            //continue;//exit;
            $responseXml = $session->sendHttpRequest($requestXmlBody);
            if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
                self::$errCode = '002';
                self::$errMsg = 'id not found';
                return false;
            }
            $data = XML_unserialize($responseXml);
            $ack = $data['AddMemberMessageAAQToPartnerResponse']['Ack'];
            $error = $data['AddMemberMessageAAQToPartnerResponse']['Errors']['LongMessage'];
            if ($ack != "Failure") {
                $data = array('reply_feedback' => $content);
                $where = " and FeedbackID='{$feedbackid}' ";
                EbayFeedbackModel::update($data, $where);
                return 'ok';
            } else {
                self::$errCode = '003';
                self::$errMsg = "批量Message失败!" . $error;
                return false;
            }
        }
    }