How to Use Steem API/transfer-history and IFTTT to sync to Slack?


This post, I show you how to use the Steem API/transfer-history and the IFTTT to sync the wallet activities to your Slack so you can get messages/updates pushed to your specific Slack channel.

Slack is a popular instant messenger, that is designed for companies and organisations. Slack is power as it can be easily integrated with third party tools with its powerful APIs. For example, it can be integrated with IFTTT, which then integrates lots of other third party tools.

“Receive a web request” is a channel that is used to call “Maker“. It is a powerful tool that can be used to receive a web request or make a request.

Let’s create a PHP script i.e. with name: check-transfer-history.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
// https://helloacm.com/how-to-use-steem-apitransfer-history-and-ifttt-to-sync-to-slack/
$id = 'justyy';
$tx = json_decode(file_get_contents("https://uploadbeta.com/api/steemit/transfer-history/?id=" . $id), true);
foreach ($tx as $r) {
  $t =  $r['time'];
  $desc = $r['time_desc'];
  $memo = $r['memo'];
  $tx = $r['transaction'];
  if (preg_match('/(\d)+\s+(second|minute|hour)s? ago/i', $desc, $matches)) {
    if (
          ($matches[2] == 'second') || 
          (($matches[2] == 'minute') && ($matches[1] == '1'))
    ) { // Capture the messages within 2 minutes
      $cmd = 'curl -s -X POST -H "Content-Type: application/json" -d \'{"value1":"'.$desc.'","value2":"'.$tx.'","value3":"'.$memo.'"}\' https://maker.ifttt.com/trigger/{steemit_transfer}/with/key/YOUR_APP_KEY';
      echo $cmd;
      shell_exec($cmd);             
    }    
  } else {
    break;
  }
}
<?php
// https://helloacm.com/how-to-use-steem-apitransfer-history-and-ifttt-to-sync-to-slack/
$id = 'justyy';
$tx = json_decode(file_get_contents("https://uploadbeta.com/api/steemit/transfer-history/?id=" . $id), true);
foreach ($tx as $r) {
  $t =  $r['time'];
  $desc = $r['time_desc'];
  $memo = $r['memo'];
  $tx = $r['transaction'];
  if (preg_match('/(\d)+\s+(second|minute|hour)s? ago/i', $desc, $matches)) {
    if (
          ($matches[2] == 'second') || 
          (($matches[2] == 'minute') && ($matches[1] == '1'))
    ) { // Capture the messages within 2 minutes
      $cmd = 'curl -s -X POST -H "Content-Type: application/json" -d \'{"value1":"'.$desc.'","value2":"'.$tx.'","value3":"'.$memo.'"}\' https://maker.ifttt.com/trigger/{steemit_transfer}/with/key/YOUR_APP_KEY';
      echo $cmd;
      shell_exec($cmd);             
    }    
  } else {
    break;
  }
}

You need to replace the Steem ID and the APP_KEY from IFTTT Receive Web Request Channel.

ifttt-configure How to Use Steem API/transfer-history and IFTTT to sync to Slack? API php SteemIt

ifttt-configure

Then, according to the return values of API steemit/transfer-history, we can customize the message pushed to Slack channel.

We then need to run the script, in the crontab, every 2 minutes, which corresponds to the PHP Script defined above.

*/2 * * * * php /path/to/check-transfer-history.php   

I sent 0.001 SBD to my wife @happyukgo

send-message How to Use Steem API/transfer-history and IFTTT to sync to Slack? API php SteemIt

send-message

And receive the message update very soon in the Slack channel.

slack-receive-messages-via-ifttt How to Use Steem API/transfer-history and IFTTT to sync to Slack? API php SteemIt

slack-receive-messages-via-ifttt

You may also like: 如何使用Steem API/transfer-history和IFTTT同步到Slack消息?

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
557 words
Last Post: How to Get Transfer History of SteemIt Accounts via SteemIt API/transfer-history?
Next Post: The Best SteemIt UpVoting Strategy Calculator in Javascript

The Permanent URL is: How to Use Steem API/transfer-history and IFTTT to sync to Slack?

Leave a Reply