예제 #1
0
function listitems()
{
    global $APPNAME, $ebayusername, $SiteId;
    $active_user = 8;
    $f_endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1';
    // Finding
    $responseEncoding = 'XML';
    // Format of the response
    $s_version = '667';
    // Shopping API version number
    $f_version = '1.4.0';
    // Finding API version number
    $appID = $APPNAME;
    //replace this with your AppID
    $debug = true;
    $sitearray = array(0 => 'EBAY-US', 2 => 'EBAY-ENCA', 3 => 'EBAY-GB', 15 => 'EBAY-AU', 77 => 'EBAY-DE');
    $globalID = $sitearray[$SiteId];
    $sellerID = $ebayusername;
    // cleanse input
    $apicall = "{$f_endpoint}?OPERATION-NAME=findItemsAdvanced" . "&version={$f_version}" . "&GLOBAL-ID={$globalID}" . "&SECURITY-APPNAME={$appID}" . "&RESPONSE-DATA-FORMAT={$responseEncoding}" . "&itemFilter(0).name=Seller" . "&itemFilter(0).value={$sellerID}" . "&paginationInput.entriesPerPage=100" . "&affliate.networkId=9" . "&affliate.trackingId=123456789" . "&affliate.customId=456";
    $resp = simplexml_load_file($apicall);
    if ($resp->ack == "Success") {
        $nbpages = ceil($resp->paginationOutput->totalEntries / 100);
    } else {
        $nbpages = 1;
    }
    //$sql="DELETE FROM user_products where ItemID>0 and UserID = $active_user";
    // mysql_query($sql);
    //echo $nbpages;die;
    /*touch($cron_file); 
        chmod($cron_file, 0777); 
    	*/
    for ($page = 1; $page <= $nbpages; $page++) {
        $my_sellings_activelist = get_my_ebay_selling_ActiveList($page);
        $xml = simplexml_load_string($my_sellings_activelist);
        $active_data = $xml->ActiveList->ItemArray->Item;
        $count_array = count($active_data);
        $minute = 0;
        $hour = 0;
        foreach ($active_data as $item) {
            $item_id = $item->ItemID;
            $item_url = $item->ListingDetails->ViewItemURL;
            $ebay_price = $item->BuyItNowPrice;
            $quantity = $item->QuantityAvailable;
            $title = $item->Title;
            $sku = $item->SKU;
            $sku = str_replace(' ', '', $sku);
            $image_url = $item->PictureDetails->GalleryURL;
            $pattern = '/^AMZ/';
            $posamaz = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^WM/';
            $poswm = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^OS/';
            $posos = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^AL/';
            $posal = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^HN/';
            $poshe = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            $pattern = '/^WF/';
            $poswa = preg_match($pattern, $sku, $matches, PREG_OFFSET_CAPTURE);
            if ($posamaz > 0) {
                $asin = str_replace('AMZ', '', $sku);
            } elseif ($poswm > 0) {
                $asin = str_replace('WM', '', $sku);
            } elseif ($posos > 0) {
                $asin = str_replace('OS', '', $sku);
            } elseif ($posal > 0) {
                $asin = str_replace('AL', '', $sku);
            } elseif ($poshe > 0) {
                $asin = str_replace('HN', '', $sku);
            } elseif ($poswa > 0) {
                $asin = str_replace('WF', '', $sku);
            } else {
                $asin = $sku;
            }
            if (!empty($asin)) {
                $sql = "SELECT * FROM ebay_asin WHERE asins='{$asin}'";
                $rs = mysql_query($sql);
                if (!mysql_num_rows($rs)) {
                    $insert = "INSERT INTO ebay_asin SET UserID={$active_user},asins='{$asin}',item_id={$item_id},ebay_title='{$title}',ebay_price= {$ebay_price},quantity={$quantity},max_quantity={$quantity},in_ebay=1,in_amazon=1";
                    mysql_query($insert);
                }
                $sql = "SELECT * FROM user_products WHERE SKU='{$sku}'";
                $rs = mysql_query($sql);
                if (!mysql_num_rows($rs)) {
                    $insert = "INSERT INTO user_products SET UserID={$active_user},ItemID={$item_id},Qty={$quantity},Price={$ebay_price},Title='{$title}',SKU='{$sku}',Image='{$image_url}',ItemUrl='{$item_url}',MaxQty={$quantity}";
                    mysql_query($insert);
                    $hour1 = $hour;
                    if ($hour1 > 23) {
                        $hour1 = $hour1 - 24;
                    }
                    $hour2 = $hour1 + 4;
                    if ($hour2 > 23) {
                        $hour2 = $hour2 - 24;
                    }
                    $hour3 = $hour2 + 4;
                    if ($hour3 > 23) {
                        $hour3 = $hour3 - 24;
                    }
                    $hour4 = $hour3 + 4;
                    if ($hour4 > 23) {
                        $hour4 = $hour4 - 24;
                    }
                    $hour5 = $hour4 + 4;
                    if ($hour5 > 23) {
                        $hour5 = $hour5 - 24;
                    }
                    $hour6 = $hour5 + 4;
                    if ($hour6 > 23) {
                        $hour6 = $hour6 - 24;
                    }
                    $command = $minute . ' ' . $hour1 . ',' . $hour2 . ',' . $hour3 . ',' . $hour4 . ',' . $hour5 . ',' . $hour6 . ' * * * wget http://dropshippingpower.com/ezonsync/cron_price_qty.php?itemid=' . $item_id;
                    append_cronjob($command);
                    $minute += 10;
                    if ($minute > 60) {
                        $minute = 0;
                    }
                    $hour += 1;
                    if ($hour > 23) {
                        $hour = 0;
                    }
                }
            }
        }
    }
}
function listitems()
{
    include 'keys.php';
    $active_user = $_SESSION['user_id'];
    $f_endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1';
    // Finding
    $responseEncoding = 'XML';
    // Format of the response
    $s_version = '667';
    // Shopping API version number
    $f_version = '1.4.0';
    // Finding API version number
    $appID = $APPNAME;
    //replace this with your AppID
    $debug = true;
    $sitearray = array(0 => 'EBAY-US', 2 => 'EBAY-ENCA', 3 => 'EBAY-GB', 15 => 'EBAY-AU', 77 => 'EBAY-DE');
    $globalID = $sitearray[$SiteId];
    $sellerID = $ebayusername;
    // cleanse input
    $apicall = "{$f_endpoint}?OPERATION-NAME=findItemsAdvanced" . "&version={$f_version}" . "&GLOBAL-ID={$globalID}" . "&SECURITY-APPNAME={$appID}" . "&RESPONSE-DATA-FORMAT={$responseEncoding}" . "&itemFilter(0).name=Seller" . "&itemFilter(0).value={$sellerID}" . "&paginationInput.entriesPerPage=100" . "&affliate.networkId=9" . "&affliate.trackingId=123456789" . "&affliate.customId=456";
    $resp = simplexml_load_file($apicall);
    if ($resp->ack == "Success") {
        $nbpages = ceil($resp->paginationOutput->totalEntries / 100);
    } else {
        $nbpages = 5;
    }
    //$sql="DELETE FROM user_products where ItemID>0 and UserID = $active_user";
    // mysql_query($sql);
    //echo $nbpages;die;
    for ($page = 1; $page <= $nbpages; $page++) {
        $my_sellings_activelist = get_my_ebay_selling_ActiveList($page);
        $xml = simplexml_load_string($my_sellings_activelist);
        $active_data = $xml->ActiveList->ItemArray->Item;
        $count_array = count($active_data);
        foreach ($active_data as $item) {
            $item_id = $item->ItemID;
            // echo $item_id.'<br>';
            $item_url = $item->ListingDetails->ViewItemURL;
            $ebay_price = $item->BuyItNowPrice;
            $quantity = $item->QuantityAvailable;
            $title = $item->Title;
            $sku = $item->SKU;
            $image_url = $item->PictureDetails->GalleryURL;
            $sql = "SELECT * FROM ebay_asin WHERE item_id = '{$item_id}' and UserID ={$active_user}";
            $rs = mysql_query($sql) or die(mysql_error());
            if (mysql_num_rows($rs)) {
                $row = mysql_fetch_array($rs);
                $amazon_price = $row['amazon_price'];
                $amazon_quantity = $row['amazon_quantity'];
                $max_quantity = $row['max_quantity'];
                $profit_ratio = $row['profit_ratio'];
                $sql = "SELECT * FROM user_products WHERE ItemID = {$item_id}";
                $rs = mysql_query($sql) or die(mysql_error());
                if (!mysql_num_rows($rs)) {
                    $title = str_replace("'", "\\'", $title);
                    $insert = "INSERT INTO user_products \n                   SET  UserID = {$active_user}, \n                        ItemID = {$item_id}, \n                        Qty = {$quantity}, \n                        Price = {$ebay_price}, \n                        Title = '{$title}', \n                        SKU = '{$sku}', \n                        Image = '{$image_url}', \n                        ItemUrl = '{$item_url}', \n                        AmazonPrice = {$amazon_price},\n                        AmazonQty = {$amazon_quantity}, \n                        MaxQty = {$max_quantity},\n                        ProfitRatio = {$profit_ratio}";
                    $update = " UPDATE ebay_asin \n                    SET quantity = {$quantity}\n                    WHERE asins='{$asin}'\n                    AND UserID={$active_user}\n        ";
                    $delete = "DELETE ast,aws FROM \n                    asins_table as ast INNER JOIN \n                    aws_asin as aws\n                    ON ast.asins = aws.asin\n                    AND ast.UserID = aws.UserID \n                    WHERE ast.asins='{$asin}'\n                    AND ast.UserID={$active_user}\n                    ";
                    //	$deleteeb="DELETE FROM ebay_asin WHERE asins='$asin' and UserID=$active_user ";
                    mysql_query($insert) or die(mysql_error());
                    mysql_query($update) or die(mysql_error());
                    mysql_query($delete) or die(mysql_error());
                    // mysql_query($deleteeb);
                }
            }
        }
    }
    //die;
}
예제 #3
0
 $user_id = $user['user_id'];
 $DEVNAME = trim($user['dev_name']);
 $APPNAME = trim($user['app_name']);
 $CERTNAME = trim($user['cert_name']);
 $token = encrypt_decrypt('decrypt', $user['token']);
 $paypal_email = trim($user['paypal_address']);
 $return_accept_option = trim($user['return_accept_option']);
 $refund_option = trim($user['refund_option']);
 $return_within_days = trim($user['return_days']);
 $duration = trim($user['listing_duration']);
 $public_key = encrypt_decrypt('decrypt', $user['amazon_publickey']);
 $private_key = encrypt_decrypt('decrypt', $user['amazon_privatekey']);
 $page = 1;
 $is_error = false;
 do {
     $my_selling_pages = get_my_ebay_selling_ActiveList($page);
     /* fetch ebay active list for the user first time, continue
         if there are many pages DO WHILE
        */
     $xml_page = new SimpleXMLElement($my_selling_pages);
     //print_r($xml_page);
     if (isset($xml_page->Errors->ErrorCode) and (str_replace('', '', $xml_page->Errors->ErrorCode) == '931' or str_replace('', '', $xml_page->Errors->ErrorCode) == '5')) {
         $is_error = true;
         break;
     } elseif (isset($xml_page->Errors)) {
         array_push($error, $xml_page->Errors);
     }
     if (!isset($pages)) {
         $pages = floatval(str_replace('', '', $xml_page->ActiveList->PaginationResult->TotalNumberOfPages));
     }
     // number of pages