+ Reply to Thread
Results 1 to 10 of 20
-
04-24-2012 03:50 AM #1Junior Member
- Join Date
- Jan 2012
- Posts
- 6
List of all merchants with coupons
Whats the easiest way to get a list of all the merchants that have coupons available?
-
04-24-2012 04:12 AM #2Senior Member
- Join Date
- Apr 2011
- Posts
- 845
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
-
04-24-2012 07:25 AM #3Junior Member
- Join Date
- Jan 2012
- Posts
- 6
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.
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?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($value, 0, 50) . '</td>';
}
echo '</tr>';
}
echo '</table>';
-
04-24-2012 08:25 AM #4Senior Member
- Join Date
- Apr 2011
- Posts
- 845
Not knowing anything about programming is going to be a bit tough there.
Basically, within this bit:
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.PHP Code:foreach ($row as $key => $value) {
}
-
04-24-2012 08:43 AM #5Junior Member
- Join Date
- Jan 2012
- Posts
- 6
Thanks for the tips. This shit is tricky, I'll mess around with it though.
Is there really only ~1300 merchants total in prosperent?
-
04-24-2012 09:24 AM #6
1300 that have had at least 1 sale. we have over 4,000 merchants.
-
04-24-2012 09:26 AM #7Senior Member
- Join Date
- Apr 2011
- Posts
- 845
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
-
04-24-2012 11:25 AM #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.
Hopefully that makes sense, I just tested it, and it worked fine. That should give an array of merchants with their coupon data.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>';
Oh one more thing, use $api->getAllData() instead of $api->getData() when calling the api.
-
04-24-2012 01:12 PM #9
-
04-24-2012 01:32 PM #10

Reply With Quote

