2015-05-04 21 views
1

如何找到此代碼工作所需的密鑰?Amazon Associates - 找不到關聯標籤,API和密鑰

<?php 
/** 
* For a running Search Demo see: http://amazonecs.pixel-web.org 
*/ 

if ("cli" !== PHP_SAPI) 
{ 
    echo "<pre>"; 
} 




defined('AWS_API_KEY') or define('AWS_API_KEY', '...'); 
defined('AWS_API_SECRET_KEY') or define('AWS_API_SECRET_KEY', '...'); 
defined('AWS_ASSOCIATE_TAG') or define('AWS_ASSOCIATE_TAG', '...'); 

// require '../lib/AmazonECS.class.php'; 
require_once (dirname(__FILE__) . '/../classes/buyamerica/AmazonECS.class.php'); 


try 
{ 
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'com', AWS_ASSOCIATE_TAG); 

    // for the new version of the wsdl its required to provide a associate Tag 
    // @see https://affiliate-program.amazon.com/gp/advertising/api/detail/api-changes.html?ie=UTF8&pf_rd_t=501&ref_=amb_link_83957571_2&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=&pf_rd_s=assoc-center-1&pf_rd_r=&pf_rd_i=assoc-api-detail-2-v2 
    // you can set it with the setter function or as the fourth paramameter of ther constructor above 
    $amazonEcs->associateTag(AWS_ASSOCIATE_TAG); 

    // First of all you have to set an another ResponseGroup. If not the request would not be successful 
    // Possible Responsegroups: BrowseNodeInfo,MostGifted,NewReleases,MostWishedFor,TopSellers 
    $amazonEcs->responseGroup('BrowseNodeInfo'); 
    // $asin = "B00625Q56U"; 
    $asin = $_REQUEST["asin"]; 
    $res = $amazonEcs->responseGroup('Large')->lookup($asin); 

    var_dump($res->Items->Item); 

} 
catch(Exception $e) 
{ 
    echo $e->getMessage(); 
} 

if ("cli" !== PHP_SAPI) 
{ 
    echo "</pre>"; 
} 

回答

3

要找到您的Associate Tag,只需登錄您的聯屬賬戶。在左邊你會發現一個框裏面寫着「Tracking ID」,這就是你需要的。或者只需點擊此鏈接:https://affiliate-program.amazon.com/gp/associates/network/your-account/manage-tracking-ids.html

在AWS管理控制檯中,導航到您的名稱(https://console.aws.amazon.com/iam/home?#security_credential)下拉列表下方的「安全證書」。在「訪問密鑰」下,您可以看到您的根訪問密鑰(分配給您在根據產品廣告API註冊時創建的根用戶)。 刪除一個,然後生成一個新的。它會顯示適當的AWS密鑰和密鑰。這些與適當的Associate Tag配對可以讓你訪問API。