352 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 50+ members
  • Has sold $10,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+6 more
danharper says

This is a quick PHP script I threw together which will check a users balance, and send them a direct message via Twitter informing them of the change.

EXAMPLE OF TWITTER NOTIFICATION : “Your new Envato Marketplace balance (account: danharper) is $205.65 (a difference of $10)”

Users can be added or removed using the manage.php page which inserts the user into a database table.

  1. Setup a Twitter account to use for the notifications.
  2. Create a database & a table named ‘users’ using the SQL query below:
    CREATE TABLE IF NOT EXISTS `users` (
      `id` int(5) NOT NULL,
      `username` varchar(60) NOT NULL,
      `apikey` varchar(120) NOT NULL,
      `twitter` varchar(45) NOT NULL,
      `balance` varchar(10) NOT NULL,
      `error` varchar(10) NOT NULL,
      PRIMARY KEY  (`id`)
    )
  3. Enter your database and Twitter settings into conf.php
  4. Run manage.php and add a new user to make sure it works.
  5. Run execute.php. The file runs through all users in the database, and checks their current balance.
NOTES :
  • Run execute.php automagically at set intervals (eg. hourly) using a cron job (Google it)
  • The user must be following the notifications account on Twitter to receive the updates.
  • You can test it out by manually changing the balance in the database.
DISCLAIMER :
  • I give no guarantee that this app is stable, and is definitely not production-ready. Just a test, really.
  • Do with this code what you like.
  • Don’t hold me responsible if your server transforms and takes over the planet while running the script (sorry).

Download

352 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 50+ members
  • Has sold $10,000+ on Envato Market
  • Had an item featured in an Envato Bundle
+6 more
danharper says

Just updated the files to be compatible with more web servers (now using cURL to retrieve the API .)
Also, I forgot to included auto_increment in the SQL query above; use this instead:

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(5) NOT NULL AUTO_INCREMENT,
  `username` varchar(60) NOT NULL,
  `apikey` varchar(120) NOT NULL,
  `twitter` varchar(45) NOT NULL,
  `balance` varchar(10) NOT NULL,
  `error` varchar(10) NOT NULL,
  PRIMARY KEY  (`id`)
);

Don’t have a webserver? I’m now running a hosted version at http://danharper.me/salesnotifier/ :)

(I hold the right to take down the hosted service at any time if problems occur.)

by
by
by
by
by
by