2016-09-20 1 views
0

질문하기 전에 SDK를 처음 접하는 초보자이며이 모든 것이 현재 당면한 문제입니다. 나는 Ebay의 정책/한계를 아직 완전히 이해하지 못할 수도 있습니다. 나는 "허용 된"또는 "적절한"것이 확실치 않아 부적절한 사용 (너무 많은 전화 또는 이와 유사한 것)으로 막히지 않습니다.davidtsadler/ebay-sdk-php를 사용하여 Ebay SDK를 사용하여 전화를 걸 수있는 방법

[질문 : 당신이 첫 번째 요청들을 통해 ID의 그들 루프가 세부 사항을 반환하는 MySQL은/​​PHP와 비슷한 또 다른 요청의 루프, 내부의 요청을 호출 할 수 있습니다.

예 : 나는 타겟 이베이 모터 판매자를 검색하고 해당 판매자로부터 일련 번호 또는 키워드 검색 그룹을 반환하고 싶습니다. (SDK에서 하나의 요청 (ItemFilter SellerID/Keywords)를 처리한다고 생각합니다.)

** 그런 다음 각 목록에 대해 각 목록에 나열된 호환 가능한 차량을 원합니다. (이것은 목록 당 "둘째"루프/요청입니다)

이것은 내가 원하는 결과를 얻으려는 내 "논리"입니다. (또는 부족함) ... 루프를 사용할 수 없지만 "참여" 스프레드 시트와 같은 compatibles에 목록을 만들 수도 있습니다.

//Two responses??..one from each request 
$response = $service->findItemsAdvanced($request); 

// how to get compatibles from item id in request/response 1 ??// 
$response2 = $service-> /* ??? */ ($request2); 


// Iterate over the items returned in the response. 
foreach ($response->searchResult->item as $item) { 
    //an easy var name for reference 
    var mylistId = $item->itemId, 
    // lets the see the ID's // 
    printf( 
     "(%s) %s\n", 
     $item->itemId, 
     $item->title 
    ); 

    //maybe the request and response is in the loop??? 
    // $requestTWO = get compatibles linked to mylistId 
    // $responseTWO = return compatibles 
    foreach ($responseTWO->searchResult->item as $compats) { 
     // print new responses 
     printf( 
     "(%s) %s\n", 
     $compats->make, 
     $compats->model, 
     $compats->year 
    ); 
} 

자세한 내용은 새로운 요청이있는 것 같습니다.

나는 분실했습니다. 감사합니다.

+0

당신이하고 싶은 일은 분명히 가능하며 당신의 논리에는 아무런 문제가 없습니다. 곧 심층적 인 대답을 드릴 수 있습니다. 그냥 쓸 시간이 필요합니다. –

답변

0

찾는 서비스가 필요한 호환성 정보를 반환하지 않습니다. 반환되는 각 항목에 대해 쇼핑 서비스에서 GetSingleItem을 별도로 호출해야합니다.

<?php 
require __DIR__.'/vendor/autoload.php'; 

use \DTS\eBaySDK\Sdk; 
use \DTS\eBaySDK\Constants; 
use \DTS\eBaySDK\Finding; 
use \DTS\eBaySDK\Shopping; 

$sdk = new Sdk([ 
    'credentials' => [ 
     'devId' => 'DEV ID', 
     'appId' => 'APP ID', 
     'certId' => 'CERT ID', 
    ], 
    'globalId' => Constants\GlobalIds::MOTORS 
]); 

/** 
* Create the service objects. 
*/ 
$finding = $sdk->createFinding([ 
    'apiVersion' => '1.13.0' 
]); 

$shopping = $sdk->createShopping([ 
    'apiVersion' => '981' 
]); 

/** 
* Create the finding request. 
*/ 
$findingRequest = new Finding\Types\FindItemsAdvancedRequest(); 
/** 
* Ask for items from these sellers. You specify up to 100 sellers. 
*/ 
$itemFilter = new Finding\Types\ItemFilter(); 
$itemFilter->name = 'Seller'; 
$itemFilter->value = [ 
    'brakemotive76', 
    'primechoiceautoparts' 
]; 
$findingRequest->itemFilter[] = $itemFilter; 
/** 
* You can optionally narrow the search down further by only requesting 
* listings that match keywords or categories. 
*/ 
//$request->keywords = 'Brake Pads'; 
//$request->categoryId = ['33560', '33561']; 

/** 
* eBay can return more than one page of results. 
* So just start at page 1 to begin with. 
*/ 
$findingRequest->paginationInput = new Finding\Types\PaginationInput(); 
$pageNum = 1; 

do { 
    $findingRequest->paginationInput->pageNumber = $pageNum; 

    $findingResponse = $finding->findItemsAdvanced($findingRequest); 

    // Handle any errors returned from the API. 
    if (isset($findingResponse->errorMessage)) { 
     foreach ($findingResponse->errorMessage->error as $error) { 
      printf(
       "%s: %s\n\n", 
       $error->severity=== Finding\Enums\ErrorSeverity::C_ERROR ? 'Error' : 'Warning', 
       $error->message 
      ); 
     } 
    } 

    if ($findingResponse->ack !== 'Failure') { 
     /** 
     * For each item make a second request to the Shopping service to get the compatibility information. 
     */ 
     foreach ($findingResponse->searchResult->item as $item) { 
      $shoppingRequest = new Shopping\Types\GetSingleItemRequestType(); 
      $shoppingRequest->ItemID = $item->itemId; 
      /** 
      * We have to tell the Shopping service to return the comaptibility and item specifics information as 
      * it will not by default. 
      */ 
      $shoppingRequest->IncludeSelector = 'ItemSpecifics, Compatibility'; 

      $shoppingResponse = $shopping->getSingleItem($shoppingRequest); 

      if (isset($shoppingResponse->Errors)) { 
       foreach ($shoppingResponse->Errors as $error) { 
        printf(
         "%s: %s\n%s\n\n", 
         $error->SeverityCode === Shopping\Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning', 
         $error->ShortMessage, 
         $error->LongMessage 
        ); 
       } 
      } 

      if ($shoppingResponse->Ack !== 'Failure') { 
       $item = $shoppingResponse->Item; 

       print("\n$item->Title\n"); 

       if (isset($item->ItemSpecifics)) { 
        print("\nThis item has the following item specifics:\n\n"); 
        foreach ($item->ItemSpecifics->NameValueList as $nameValues) { 
         printf(
          "%s: %s\n", 
          $nameValues->Name, 
          implode(', ', iterator_to_array($nameValues->Value)) 
         ); 
        } 
       }  

       if (isset($item->ItemCompatibilityCount)) { 
        printf("\nThis item is compatible with %s vehicles:\n\n", $item->ItemCompatibilityCount); 

        foreach ($item->ItemCompatibilityList->Compatibility as $compatibility) { 
         foreach ($compatibility->NameValueList as $nameValues) { 
          if ($nameValues->Name != '') { 
           printf(
            "%s: %s\n", 
            $nameValues->Name, 
            implode(', ', iterator_to_array($nameValues->Value)) 
           ); 
          } 
         } 
         printf("Notes: %s \n", $compatibility->CompatibilityNotes); 
        } 
       } 
      } 
     } 
    } 

    $pageNum += 1; 

} while ($pageNum <= $findingResponse->paginationOutput->totalPages); 
+0

David에게 감사드립니다. 루프를 요청하는 것이 부적절한 것인지, 예가 철저하고 명확한 지 확실하지 않았습니다. 매우 감사드립니다. – zzipper72

+0

David, 쇼핑은 독자적으로 반환하지 않았기 때문에 호환성이라고 불렀습니다. (귀하의 메모를 이해할 경우) ... 제조업체 번호 (어디에서 "전화"인지)는 어디에 있습니까? 나는 이베이 제품 창조자. - 이베이 모터스는 상당히 어려울 것 같습니다. – zzipper72

+0

제조업체 부품 번호는 일반적으로 eBay가 Item Specifics라고 부르는 것에 저장됩니다. 이 예제를 업데이트하여 아이템 특성을 얻도록했습니다. MPN을 찾으려면 if ($ nameValues-> Name === 'Manufacturer Part Number') 행을 따라 뭔가를해야합니다. {$ mpn = $ nameValues-> Value [0]; } 이것은 아이템 특성이 MPN에 대한 특정 필드를 가지고 있지 않기 때문입니다. –

관련 문제