REST API: Search Questions

Discussion in 'Commission Junction' started by hovesh07, Sep 14, 2010.

  1. #1
    1. How do I search for an exact string, like "knit hat" ?
    2. Is there a way to search just titles and not descriptions?
     
    hovesh07, Sep 14, 2010 IP
  2. markowe

    markowe Well-Known Member

    Messages:
    1,136
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    165
    #2
    1. You know, I have tried every possible combination just now with your example and I don't think you can. Which is lame, but there you go.
    2. Again, I don't think you can unfortunately, only "keywords found in the advertiser’s name, the product name or the product description" as it says in the docs

    Yes, CJ's API is very weak unfortunately, they really need to improve it drastically to even come close to Amazon's or eBay's. For advanced stuff it may be better to order CSV files to be sent daily and import them into your database. Those files are really chaotic, but you can at least do proper searching on them.
     
    markowe, Sep 15, 2010 IP
  3. phpPig

    phpPig Peon

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I wrote a script using REST..I entered keywords "knit hat" and this is the page of the results. NOTE: The first five are Amazon links.

    You will notice that under the title and the short url the keywords are displayed.

    http://emerchantsmall.com/blog/4-tobd.html

    Here is some of the code that I use to make the call:
    
    $website = "CJ PID";
    
            $devkey ="Your API Key";
    $keywords = "knit hat";
    
    $keywords= str_replace(" ","+",$keywords);
    
    $advertiserId = "joined";
    
    $maxResults = 10;
    
    
    $url = "https://product-search.api.cj.com/v2/product-search?&website-id=$websiteId&advertiser-ids=$advertiserId&keywords=$keywords&records-per-page=$maxResults";
    
    
    PHP:
     
    Last edited: Sep 16, 2010
    phpPig, Sep 16, 2010 IP
  4. markowe

    markowe Well-Known Member

    Messages:
    1,136
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    165
    #4
    Did you ever get this solved? I just did a lot more fiddling with REST (I used to use SOAP, but it just seems to be broken, I am giving up on it) - I realised I was having some trouble with it because I did not do as above, replace spaces with plus signs in the keywords (it says it in the instructions but I didn't get it, I thought you had to URLencode, but that's not the issue). If you don't do that step you won't get relevant results. However, there is still no way to get results for an exact match with two keywords.

    I also have a need to search on the product name soon (WHY this is not possible now, I don't know) - the way I plan to do it is import a whole load of results into my database and then JUST select on the name field. Again, WHY can this not be done through the API!? If you want to search for, say 'used cellphone' you will also get results for cellphones that have 'used' in the description, like "...this phone is USED for...' Totally useless...
     
    markowe, Sep 22, 2010 IP