2016-08-10 7 views
0

誰でもこの問題を解決できますか? ページあたり50個のエントリでAPI呼び出しを行っています。 結果が表示されますが、次のページを表示するにはどうすればよいですか? ページネーションの使い方は?私はどこから始めるべきかの手がかりを持っていません。 私は本当にここでいくつかの助けが必要です。 おかげebay-api "findItemsByKeywords" codigniter 3のページ番号

は、これはここで、コントローラ

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; 

である私が正しく理解し、あなたは結果の、1ページ以上をロードしたい場合は、POSTリクエスト

<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

これは私のページです。https://kikoza.com/index.php/ebayapps – roni

答えて

0

です。この場合、最初に取得するページの総数に応じて、多数のAPIリクエストを作成する必要があります。

あなたは4ページが必要です - 関数を4回実行し、各ループでpaginationInput.pageNumberを増やす必要があります。

これが役に立ちます。