BazaarPush
BazaarPush is a wrapper based on the popular Laravel Framework which regularly logs into your CafeBazaar accounts, parses pages and pushes reports of new events such as sales on to your devices (via PushBullet)., (*1)
, (*2)
Installation
Would you rather a video (in Persian) ? Aparat, (*3)
Using composer, add this package dependency to your Laravel's composer.json :, (*4)
{
"require": {
"nikapps/bazaar-push": "1.*"
}
}
Update composer :, (*5)
composer update
Add this package provider in your providers array [app/config/app.php]
:, (*6)
'Nikapps\BazaarPush\BazaarPushServiceProvider'
Run migrations for this package, this will add a table to your database named bazaar_sale
which keeps track of your sale records.
Run :, (*7)
php artisan migrate --package="nikapps/bazaar-push"
Publish configuration file.
Run :, (*8)
php artisan config:publish nikapps/bazaar-push
Run :, (*9)
php artisan
if you see a bazaarpush
command namespace, you are all set to go !, (*10)
Configuration
Open [app/config/packages/nikapps/bazaar-push/config.php]
.
Setup your CafeBazaar credentials, each one of them as an associative array like the example below :, (*11)
"credentials" => [
[
"email" => "first@account.com",
"password" => "secret"
],
[
"email" => "second@account.com",
"password" => "top secret"
],
.
.
.
]
Setup your PushBullet accounts like the example, get your PushBullet API key from PushBullet, (*12)
"pushbulletKeys" => [
[
"key" => "FirstAccountKey",
"accounts" => ['first@account.com'] // declare CafeBazaar accounts as an array which you want to get reports from them
"devices" => ['LGENexus 4'] // declare your devices as an array which you want to get pushes on them
],
[
"key" => "SecondAccountKey",
"accounts" => null, // you can pass null to get reports from all of your declared CafeBazaar accounts in credentials section
"devices" => null // you can pass null to get pushes on all of the devices associated with this PushBullet account.
],
.
.
.
],
Adding Cronjob
This cronjob runs the checking command each 20 minutes and fetches the new sales from CafeBazaar. Also, it will report new events as a push to your devices.
Don't forget to change the artisan path :), (*13)
*/20 * * * * php /absolute/path/to/your/artisan bazaarpush:sale >/dev/null 2>&1
Probable issues
- This project parses CafeBazaar pages and fetches required data from them, if CafeBazaar changes the current panel layout we need to change the matching Regular Expression patterns. Our recomendation is to set a watcher on this project to keep up with the updates.
- At this moment CafeBazaar just gives the latest 100 sale records, so if you have more than 100 sale records in 20 minutes (#RichKidsOfIran !), you'll lose some of the records.
Future
Pushing the daily income and also new comments.
Wanna contribute ? simply fork this project and make a pull request !, (*14)
Dependencies
License
This project released under the MIT License., (*15)
/*
* Copyright (C) 2014 NikApps Team.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* 1- The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* 2- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
Donation
, (*16)