Results 1 to 8 of 8

Thread: Custom Product Search By Keyword and Merchant

  1. #1
    Member
    Join Date
    November 29th, 2010
    Posts
    138
    Custom Product Search By Keyword and Merchant
    Here is the code ... it fetched all the data. I need just an affiliate URL:

    So I need to parse just the first result probably $ro ... let me know what regex would this be as i never worked with arrays?

    PHP Code:

    <?php

    $api_key 
    "some number";
    $publisher_id "some number";
    $keyword "bue widgets";

        require_once(
    'Prosperent_Api.php');

        
    $prosperentApi = new Prosperent_Api(array(
               
    'api_key'       =>      $api_key,
               
    'query'   =>    $keyword,
               
    'visitor_ip'     => $_SERVER['REMOTE_ADDR'],
        ));


        
    $prosperentApi->set_filterMerchant('Zappos');

        
    //fetch the result
        
    $prosperentApi->fetch();

        
            
     
    //   ............................   TABLE . .................................................     
        
        
        //iterate through the data response and 

        
    echo '<table border="1">';
        
    $i=0;
        foreach (
    $prosperentApi->getData() as $row)
        {
            
    /*
             * if this is the first row, set the titles
             */
            
    if ($i++ == 0)
            {
                echo 
    '<tr>';

                foreach (
    array_keys($row) as $th)
                {
                    echo 
    '<th>' $th '</th>';
                }

                echo 
    '</tr>';
            }

            echo 
    '<tr>';

            foreach (
    $row as $value)
            {
                echo 
    '<td>' $value '</td>';
            }

            echo 
    '</tr>';
        }
        echo 
    '</table>'

      
    // ............................  TABLE END ...........................
        
        
        
    ?>

  2. #2
    Member
    Join Date
    November 29th, 2010
    Posts
    138
    Also is this the correct code for getting commission. No need to somehow use $publisher_id.

  3. #3
    Member
    Join Date
    March 28th, 2013
    Posts
    6
    Simple enough. Accessing nodes in an array is as simple as using square brackets []. The nodes are associative, meaning that that can be access as strings. So, to get to the affiliate url, we reference $row['affiliate_url'], with single quotes around affiliate_url.

    To get to the affiliate url, forget the table code and use this:

    PHP Code:
    <?php 

    $api_key 
    "some number"
    $publisher_id "some number"
    $keyword "bue widgets"

        require_once(
    'Prosperent_Api.php'); 

        
    $prosperentApi = new Prosperent_Api(array( 
               
    'api_key'       =>      $api_key
               
    'query'   =>    $keyword
               
    'visitor_ip'     => $_SERVER['REMOTE_ADDR'], 
        )); 


        
    $prosperentApi->set_filterMerchant('Zappos'); 

        
    //fetch the result 
        
    $prosperentApi->fetch(); 

        foreach (
    $prosperentApi->getData() as $row)
        {
            echo 
    $row['affiliate_url'];
            echo 
    '<br />';
        }

    ?>
    I'm not sure what you want to do with the affiliate url after you have it, so this code will only get you so far.

  4. Thanks From:

  5. #4
    Member
    Join Date
    March 28th, 2013
    Posts
    6
    As for the commissions, that is a different endpoint. Refer to our documentation on the commissions endpoint on how to retrieve commissions. But, also remember, our reporting interface gives you the same data and is much easier to navigate than writing an API script.

  6. Thanks From:

  7. #5
    Member
    Join Date
    November 29th, 2010
    Posts
    138
    I am integrating this in cjniche plugin. All i need is affiliate url though "price would be nice" but i think i will figure this out myself.

    Code:
    $productprice =  $row['price'];

  8. #6
    Member
    Join Date
    March 28th, 2013
    Posts
    6
    You got it. The available node keys are:

    'catalogId'
    'productId'
    'affiliate_url'
    'image_url'
    'keyword'
    'keywords'
    'celebrity'
    'description'
    'category'
    'price'
    'price_sale'
    'currency'
    'merchant'
    'brand'
    'upc'
    'isbn'
    'sales'
    'minPrice'
    'maxPrice'
    'minPriceSale'
    'maxPriceSale'
    'groupCount'

    Or, do get a printout of what is inside each row, simply var_dump($row)

  9. Thanks From:

  10. #7
    Member
    Join Date
    November 29th, 2010
    Posts
    138
    Quote Originally Posted by Prosperent Mike View Post
    As for the commissions, that is a different endpoint. Refer to our documentation on the commissions endpoint on how to retrieve commissions. But, also remember, our reporting interface gives you the same data and is much easier to navigate than writing an API script.
    No I do not need commission to be show. I didn't expressed myself properly, i wanted to ask is this correct affiliate link, because your wordpress plugin (SUITE) suite is actually using both API key and [published ID .. so both of them are maybe needed for tracking

  11. #8
    Member
    Join Date
    March 28th, 2013
    Posts
    6
    Yes, it's the correct affiliate url

  12. Thanks From:

  13. Newsletter Signup

Similar Threads

  1. Merchant Product Search - Is This New?
    By John Powell in forum AvantLink -AV
    Replies: 3
    Last Post: October 21st, 2009, 12:44 PM
  2. Using Custom Search
    By HardwareGeek in forum Search Engine Optimization
    Replies: 0
    Last Post: September 15th, 2008, 01:38 AM
  3. Replies: 5
    Last Post: March 15th, 2007, 02:01 AM
  4. Replies: 5
    Last Post: April 4th, 2004, 07:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •