ebay-api“findItemsByKeywords”在codigniter 3中的分页

时间:2016-08-10 13:46:45

标签: codeigniter ebay ebay-api

任何人都可以帮我解决这个问题吗? 我正在进行API调用,每页有50个条目。 我得到了结果,但我怎样才能显示下一页? 如何使用分页?我不知道从哪里开始。 我真的需要一些帮助。 感谢

这是控制器

    if (!empty($_POST['submit'])) {
        $aaa = $_POST['kikozasearch'];
    }else {
        $aaa = $_POST['kikozasearch'];
    }
    // API request variables
    $endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1';  // URL to call
    $version = '1.0.0';  // API version supported by your application
    $appid = '';  // Replace with your own AppID
    $globalid = 'EBAY-US';  // Global ID of the eBay site you want to search (e.g., EBAY-DE)
    $query = $aaa;  // You may want to supply your own query
    $safequery = urlencode($query);  // Make the query URL-friendly
    $i = '0';  // Initialize the item filter index to 0

    $apicall = "$endpoint?";
    $apicall .= "OPERATION-NAME=findItemsByKeywords";
    $apicall .= "&SERVICE-VERSION=$version";
    $apicall .= "&SECURITY-APPNAME=$appid";
    $apicall .= "&GLOBAL-ID=$globalid";
    $apicall .= "&keywords=$safequery";
    $apicall .= "&paginationInput.pageNumber=$currentpage";
    $apicall .= "&paginationInput.entriesPerPage=50";
    //$apicall .= "&paginationOutput.totalPages";
    $apicall .= "$urlfilter";

    // Load the call and capture the document returned by eBay API
    $resp = simplexml_load_file($apicall);

    // Check to see if the request was successful, else print an error
    if ($resp->ack == "Success") {
      $results = '';
      // If the response was loaded, parse it and build links  
      foreach($resp->searchResult->item as $item) {
        $pic   = $item->galleryURL;
        $link  = $item->viewItemURL;
        $title = $item->title;


        // For each SearchResultItem node, build a link and append it to $results
        $results .= "<div><img src=\"$pic\"></td><td><a href=\"$link\">$title</a>$pag</div>";
      }
    }
    // If the response does not indicate 'Success,' print an error
    else {
      $results  = "<div class='alert alert-danger'><h4>Oops! The request was not successful. Make sure you are using a valid ";
      $results .= "AppID for the Production environment.</h4></div>";
    }
    echo "We found: ".$resp->paginationOutput->totalEntries . " resaults!";
    echo "<div class='alert alert-info'>".$results."</div>";
    // echo  $resp->paginationOutput->entriesPerPage;
    // echo "<br>";
    // echo $resp->paginationOutput->totalEntries;
    // echo "<br>";
    // echo $resp->paginationOutput->totalPages;



        echo $currentpage;
        echo "/".$resp->paginationOutput->totalPages;
        echo "<br />";


    $totalpages = $resp->paginationOutput->totalPages;

这是帖子请求

<script>
    $(document).ready(function(){

        $('#form').on('submit', function(info){
            info.preventDefault();
                $.post('<?php echo base_url();?>index.php/ebayapps/searchitem',
                        $('#form').serialize(),
                        function(data){
                            $('#resaults').html(data);
                        }
                 );


        }); // keyup
});
</script>

0 个答案:

没有答案