Join Free
  • Inbox
    + Reply to Thread
    Page 1 of 2 1 2 LastLast
    Results 1 to 10 of 20
    1. #1

      List of all merchants with coupons

      Whats the easiest way to get a list of all the merchants that have coupons available?

    2. #2
      Use the Merchant API end-point and do a search in the Coupon API end-point per merchant. Then take a note of which merchant's had data returned. Now you have a list of all Merchant's that has coupons available

    3. #3
      I searched around on the forum, but I couldn't find any information about how to use one endpoint to search in another endpoint. Or use the results returned from one endpoint and feed them into another endpoint. I don't know anything about programming.

      PHP Code:
      <?php 

          
      require_once('Prosperent_Api.php'); 

          
      $prosperentApi = new Prosperent_Api(array(
          
          
      'accessKey'    => 'key',
          
      'limit' => 1300

           
      )); 


          
      $prosperentApi->fetchMerchant(); 

          
      //iterate through the data response 
          
      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 $key => $value
              { 
                  if (
      'logoUrl' == $key
                  { 
                      echo 
      '<td><img src="' $value '" /></td>'
                      continue; 
                  } 

                  echo 
      '<td>' substr($value050) . '</td>'
              } 

              echo 
      '</tr>'
          } 
          echo 
      '</table>';
      I used the above code to successfully return a list of all the merchants, but I'm not sure how I can use the coupon endpoint to further process the results? Can you point me in the right direction?

    4. #4
      Not knowing anything about programming is going to be a bit tough there.

      Basically, within this bit:

      PHP Code:
      foreach ($row as $key => $value) {


      You will call the coupon API end-point (there should be some documentation in the Dashboard) and pass the merchant name as a filter/search parameter. Then you check if any data is returned, if not, no coupons available for the merchant and you can "mark" it as not having any.

    5. #5
      Thanks for the tips. This shit is tricky, I'll mess around with it though.

      Is there really only ~1300 merchants total in prosperent?

    6. #6
      1300 that have had at least 1 sale. we have over 4,000 merchants.

    7. #7
      Nope, there's quite a bit more. The 1300 you see is the logo's they have available (I think). Try adding a limit of 10000 and checking

    8. #8
      Okay If I'm understanding correctly what you're trying to accomplish, (using the results from one endpoint to search another endpoint), you could try this. Basically, you could just create a class and wrap the api call inside of a method which will be used twice, once for your getting a list of merchants, and second for using that merchant list as the filterMerchant parameter.

      Here is a simple class I've created for you that should do what you want. So we have a setter method that will be called upon instantiation and set the merchant list.

      We begin with $this->_merch being null in the setMerch() method because when we first call the api you're just needing a list of merchants, no filtering needed.

      The second api call in getCoupData(), we have already set $this->_merch to the array of merchants which will be used in the filterMerchant param. This method will return coupon data filtered by that provided list of merchants.

      PHP Code:
      class merchCoups
      {
          public function 
      __construct()
          {
              require_once(
      'Prosperent_Api.php'); 
          
              
      $this->_merch null;
              
      $this->setMerch();
          }
          
          public function 
      getCoupData()
          {
              
      $api $this->api();
          
              
      $api->fetchCoupons();
              
      $api->getCoupons();
          
              return 
      $api->getAllData();
          }
          
          public function 
      setMerch()
          {
              
      $api $this->api();
          
              
      $api->fetchMerchant();
          
              
      $data $api->getAllData();
          
              foreach (
      array_keys($data) as $k)
              {
                      
      $this->_merch[$k] = $data[$k]['merchant'];
              }
          
          }
          
          public function 
      api()
          {
              
      $prosperentApi = new Prosperent_Api(array(
                  
      'api_key'        => <your_api_key>,
                  
      'limit'          => 20,
                  
      'filterMerchant' => $this->_merch
              
      ));
          
              return 
      $prosperentApi;
          }
      }

      // So then >>>>>
      $data = new merchCoups();

      echo 
      '<pre>' print_r($data->getCoupData(), true) . '</pre>'
      Hopefully that makes sense, I just tested it, and it worked fine. That should give an array of merchants with their coupon data.

      Oh one more thing, use $api->getAllData() instead of $api->getData() when calling the api.

    9. #9
      Quote Originally Posted by Prosperent Alex View Post
      Okay If I'm understanding correctly what you're trying to accomplish, (using the results from one endpoint to search another endpoint), you could try this. Basically, you could just create a class and wrap the api call inside of a method which will be used twice, once for your getting a list of merchants, and second for using that merchant list as the filterMerchant parameter.

      Here is a simple class I've created for you that should do what you want. So we have a setter method that will be called upon instantiation and set the merchant list.

      We begin with $this->_merch being null in the setMerch() method because when we first call the api you're just needing a list of merchants, no filtering needed.

      The second api call in getCoupData(), we have already set $this->_merch to the array of merchants which will be used in the filterMerchant param. This method will return coupon data filtered by that provided list of merchants.

      PHP Code:
      class merchCoups
      {
          public function 
      __construct()
          {
              require_once(
      'Prosperent_Api.php'); 
          
              
      $this->_merch null;
              
      $this->setMerch();
          }
          
          public function 
      getCoupData()
          {
              
      $api $this->api();
          
              
      $api->fetchCoupons();
              
      $api->getCoupons();
          
              return 
      $api->getAllData();
          }
          
          public function 
      setMerch()
          {
              
      $api $this->api();
          
              
      $api->fetchMerchant();
          
              
      $data $api->getAllData();
          
              foreach (
      array_keys($data) as $k)
              {
                      
      $this->_merch[$k] = $data[$k]['merchant'];
              }
          
          }
          
          public function 
      api()
          {
              
      $prosperentApi = new Prosperent_Api(array(
                  
      'api_key'        => <your_api_key>,
                  
      'limit'          => 20,
                  
      'filterMerchant' => $this->_merch
              
      ));
          
              return 
      $prosperentApi;
          }
      }

      // So then >>>>>
      $data = new merchCoups();

      echo 
      '<pre>' print_r($data->getCoupData(), true) . '</pre>'
      Hopefully that makes sense, I just tested it, and it worked fine. That should give an array of merchants with their coupon data.
      Alex, thanks VERY much for putting this kind of effort into a response. This is awesome man, makes me want to buy another bottle of scotch through my own Prosp link!

      Quote Originally Posted by Prosperent Alex View Post
      Oh one more thing, use $api->getAllData() instead of $api->getData() when calling the api.
      This change has caused me a couple headaches

    10. #10
      Quote Originally Posted by Zaphod View Post
      Alex, thanks VERY much for putting this kind of effort into a response. This is awesome man, makes me want to buy another bottle of scotch through my own Prosp link!
      No problem. Buy two and send me one haha.

    Posting Permissions

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