1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Amazon Product Advertising API Signature - PHP

Discussion in 'Amazon' started by myhart, Jun 3, 2009.

  1. myhart

    myhart Peon

    Messages:
    228
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #61
    I will try to check out the signature code you posted later tonight.
    SEMrush
     
    myhart, Sep 11, 2009 IP
    SEMrush
  2. nas80

    nas80 Greenhorn

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #62
    Try this step :
    Don't fill the $SubscriptionID in config.php, but fill the $AWSAccessKeyId
    At the aws4class.php find the line :
    xml_parse_into_struct($parser,$data,&$d_ar,&$i_ar);
    Remove the '&' character so the line become like this :
    xml_parse_into_struct($parser,$data,$d_ar,$i_ar);
     
    nas80, Sep 11, 2009 IP
  3. myhart

    myhart Peon

    Messages:
    228
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #63
    busanamuslim the code that you posted works in both the "New" and "Old" versions of ASM2. However the SecretAccessKey needs to be inserted into the signature code in the aws4class.php file for it to work. In the config.php file I added my AWSAccessKeyId.

    If I understand correctly you are "testing" with an updated version of ASM2 which had the signature code included? You might try a fresh upload of the latest version available at http://www.freekrai.net

    As nas80 suggested the "&" in the following line can be a problem on some servers.

    xml_parse_into_struct($parser,$data,&$d_ar,&$i_ar);
    Code (markup):
    What version of PHP are you using? Older versions of PHP4 may not support the mhash function. If this is the case try substituting the following line as suggested in one of my earlier posts.

    $Signature= base64_encode(mhash(MHASH_SHA256, $PrependString, $SecretAccessKey));
    Code (markup):
     
    Last edited: Sep 12, 2009
    myhart, Sep 12, 2009 IP
  4. busanamuslim

    busanamuslim Guest

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #64
    In which part of aws4class.php to insert SecretAccessKey? I upload a fresh aws4class.php I just downloaded from the link provided.

    This is how I write in config.php:
       $SubscriptionID = "";
       $AWSAccessKeyId = 'xxxxxxxx';
       $SecretAccessKey = "xxxxxxx";
    
    Code (markup):
    As with PHP I use version 5.2.9.
     
    busanamuslim, Sep 14, 2009 IP
  5. myhart

    myhart Peon

    Messages:
    228
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #65
    If you are adding the signature code that you posted to an "old" version of ASM2 (pre-API signature code)? You would add the SecretAccessKey to the following line in the signature code it's self.

    $SecretAccessKey = "";
    Code (markup):
    No need to add or change anything in the config.php file as long your AWSAccessKeyId is already included.

    From one of your earlier posts "I downloaded the new ASM2 with this signature thing inside." However the code that you posted is not what is included with the latest version of ASM2. Which may be part of the problem? Probably be a good idea to echo the API request "$url" both before and after the signature code is added. Looking closely for problems with the parameters.

    However at this point I would strongly suggest loading a fresh "TEST" copy of the ASM2 script from the link I posted. Then add your AWSAccessKeyId and SecretAccessKey in the config.php file. With this new version of the ASM2 script there is no need to change or add anything in the aws4class.php file. As long as everthing else is setup properly the script should display Amazon products. If not there may be another problem totally unrelated to the Amazon API signature code.
     
    myhart, Sep 15, 2009 IP
  6. busanamuslim

    busanamuslim Guest

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #66
    Thanks myhart, I will recheck everything as you suggested and will post any results here.
    Have a nice day.
     
    busanamuslim, Sep 16, 2009 IP
  7. lunarpages

    lunarpages Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #67
    @myhart

    No data found on my site, I used the new ASM2, would you provide your asm.zip? thank you
     
    lunarpages, Sep 17, 2009 IP
  8. lunarpages

    lunarpages Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #68
    Same problem, Do you have resoloved it?
     
    lunarpages, Sep 17, 2009 IP
  9. piron

    piron Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #69
    It might have to do something with the server you uploaded it to. I was playing around with asm on some free webspace with free php support and had the "no data" message. I tried a different server without changing anything and it populated my front page with dvds below the welcome message. Both servers say they support php 5 so I'm not 100% what was different.

    Does anyone know the exact requirements needed to run ASM2?
     
    piron, Sep 18, 2009 IP
  10. myhart

    myhart Peon

    Messages:
    228
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #70
    Sorry for the delay in responding! Yes I believe some free hosts may block the port needed to access Amazon's API. I don't know the requirements for ASM2 other than I believe it needs at least PHP4.

    "would you provide your asm.zip?" What I have is from the link I posted above.

    If you have the latest version of ASM2 uploaded and it doesn't work. I would suggest echoing the signed Amazon Product API URL in the aws4class.php file. Copy the API URL to your browser and see if you get a signed API XML feed back from Amazon. If the Amazon API data is returned I would guess the problem may be your host???
     
    Last edited: Sep 22, 2009
    myhart, Sep 22, 2009 IP
  11. SimonHa

    SimonHa Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #71
    I am grateful that you posted this. I couldn't have never figured it out by myself. Many thanks!!!!
     
    SimonHa, Oct 15, 2009 IP
  12. shuriken

    shuriken Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #72
    Thank you so much
     
    shuriken, Oct 25, 2009 IP
  13. zealot777

    zealot777 Peon

    Messages:
    448
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #73
    It worked perfectly for me. Thanks!! Been trying to figure out how to do this for almost a day.
     
    zealot777, Nov 14, 2009 IP
  14. busanamuslim

    busanamuslim Guest

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #74
    I use hostmons***.com hosting, perhaps this is the case?
     
    busanamuslim, Feb 11, 2010 IP
  15. farazch

    farazch Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #75
    the above code is very helpful and with its help i was able to generate correct timestamp and signature for ItemLookup operation.But when i try to use same code for ItemSearch operation,it start giving me error or "not a valid value for Signature. Please change this value and retry your request".Parameters r different for ItemSearch operation like SearchIndex,Keywords,ItemPage=$ItemPage.
    Can u plz give an example for ItemSearch operation in php.Thanks.
     
    farazch, Mar 3, 2010 IP
  16. busanamuslim

    busanamuslim Guest

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #76
    Myhart and all friendly guys here, I found a weird solution to my problem, as follows:

    After following Myhart's suggestion to echo $url before and after the signature code, finally I noticed that the $url echoes this weird part: "&AWSAccessKeyId=us". Then I recall that this "us" is the value of $locale defined in config.php file. Therefore I simply tried changing this $locale value to my AWSAccessKeyId. And what happens? Bingo .... the $url echoes a correct "&AWSAccessKeyId=myAWSAccessKeyId" and, the script works well!

    I'm too novice to able explaining why this weird thing happens. Any thoughts, perhaps?
     
    busanamuslim, Apr 2, 2010 IP
  17. powerbeer

    powerbeer Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #77
    thank for CODe
     
    powerbeer, Apr 5, 2010 IP
  18. adbox

    adbox Well-Known Member

    Messages:
    906
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    155
    Digital Goods:
    1
    #78
    Why is unsafe to share your secret access key? I want to build an API that looks up products by asin; but why bother having people create their own keys; why can't they just use mine; Is it a risk to me?
     
    adbox, Oct 15, 2010 IP
  19. freshdevelopment

    freshdevelopment Notable Member

    Messages:
    1,303
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    240
    #79
    It will use your quota - Amazon provide you only so many calls to the API depending on how many sales you generate. If you let other users use your API key etc. you also are at risk of getting your account closed for someone elses bad practice.
     
    freshdevelopment, Oct 15, 2010 IP
  20. dev_ch7

    dev_ch7 Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #80
    Hi,
    Thanks for this section to understand Amazon API in a easy way.

    Can you please provide the full working code for the new version (2011-08-01)? I downloaded Product Advertising PHP Soap Library from Amazon but that's not working. Getting the below mentioned error.

    SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl' : Start tag expected, '<' not found

    I did not get any solution for this yet. Any help on this will be appreciated.
     
    Last edited: Apr 11, 2013
    dev_ch7, Apr 11, 2013 IP