Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2.  
  3. set_time_limit(0);
  4. date_default_timezone_set('UTC');
  5. require_once ('../vendor/autoload.php');
  6.  
  7. /////// CONFIG ///////
  8. $username = 'kranky.karl';
  9. $password = 'zmpq1234';
  10. $debug = true;
  11. $truncatedDebug = false;
  12. //////////////////////
  13.  
  14. $ig = new \InstagramAPI\Instagram($debug, $truncatedDebug);
  15.  
  16. try {
  17. $ig->login($username, $password);
  18. } catch (\Exception $e) {
  19. echo 'Something went wrong: '.$e->getMessage()."\n";
  20. exit(0);
  21. }
  22.  
  23. $loop = \React\EventLoop\Factory::create();
  24. $push = new \InstagramAPI\Push($loop, $ig, $logger);
  25. $push->on('incoming', function (\InstagramAPI\Push\Notification $push) {
  26. printf('%s%s', $push->getMessage(), PHP_EOL);
  27. });
  28.  
  29. $push->on('direct_v2_message', function (\InstagramAPI\Push\Notification $push) {
  30. printf(
  31. 'Thread ID: %s. Thread item ID: %s.%s',
  32. $push->getActionParam('id'),
  33. $push->getActionParam('x'),
  34. PHP_EOL
  35. );
  36. });
  37. $push->on('error', function (\Exception $e) use ($push, $loop) {
  38. printf('[!!!] Got fatal error from FBNS: %s%s', $e->getMessage(), PHP_EOL);
  39. $push->stop();
  40. $loop->stop();
  41. });
  42. $push->start();
  43.  
  44. $loop->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement