PHP Classes

PHP Instagram Feed Notification: Send Instagram posts by email

Recommend this page to a friend!
  Info   View files Example   View files View files (1)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2022-11-08 (10 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 47 All time: 10,584 This week: 125Up
Version License PHP version Categories
ig-feed-notification 1.0.0MIT/X Consortium ...5Email, PHP 5, Social Networking
Description 

Author

This package can send Instagram posts by email.

It provides classes that store posts retrieved from an Instagram user feed in a database table.

The package can also return posts stored in the database and send them to a given email address.

The package retrieves the destination email address of these messages from environment variables.

Innovation Award
PHP Programming Innovation award nominee
November 2022
Number 6
Some people avoid spending too much time on social networks when they consider those social networks a distraction that is not worth their time.

Still, those who want to follow specific profiles would prefer following those profiles if they did not have to go daily to the profile pages.

This package provides a solution that sends email messages only when new posts of specific Instagram profiles are published.

Manuel Lemos
Picture of Chun-Sheng, Li
  Performance   Level  
Name: Chun-Sheng, Li <contact>
Classes: 22 packages by
Country: Taiwan Taiwan
Age: 30
All time rank: 24126 in Taiwan Taiwan
Week rank: 43 Up1 in Taiwan Taiwan Up
Innovation award
Innovation award
Nominee: 12x

Winner: 1x

Example

<?php

date_default_timezone_set
('Africa/Lagos');

require_once
__DIR__ . '/./vendor/autoload.php';

use
Instagram\Storage\CacheManager;
use
Instagram\Api;
use
Dotenv\Dotenv;
use
IgFeedNotification\CheckPost;
use
IgFeedNotification\SendMail;

@
mkdir('./ig_cache');

$cache = new CacheManager('./ig_cache');

$userNamesInstruction = [
   
'user_name1' => 'Give him 10k Likes',
   
'user_name2' => 'Give 10 comments',
];

foreach (
$userNamesInstruction as $userName => $instruction) {
   
$api = new Api($cache);

   
$api->setUserName($userName);

   
$dotenv = new Dotenv(__DIR__);
   
$dotenv->load();

   
$checkPost = new CheckPost();

    try {
       
// First page

        /** @var \Instagram\Hydrator\Component\Feed $feed */
       
$feed = $api->getFeed();

        echo
'============================' . "<br/>";

        echo
'User Informations : ' . "<br/>";
        echo
'============================' . "<br/><br/>";

        echo
'ID : ' . $feed->getId() . "<br/>";
        echo
'Full Name : ' . $feed->getFullName() . "<br/>";
        echo
'UserName : ' . $feed->getUserName() . "<br/>";
        echo
'Following : ' . $feed->getFollowing() . "<br/>";
        echo
'Followers : ' . $feed->getFollowers() . "<br/><br/>";

        echo
'============================' . "<br/>";
        echo
'Medias first page : ' . "<br/>";
        echo
'============================' . "<br/><br/>";

       
$msg = '';

       
/** @var \Instagram\Hydrator\Component\Media $media */
       
foreach ($feed->getMedias() as $media) {
           
$msg .= 'User Name : ' . $feed->getUserName() . "<br/>";
           
$msg .= 'Caption : ' . $media->getCaption() . "<br/>";
           
$msg .= 'Link : ' . $media->getLink() . "<br/>";
           
$msg .= 'Instructions: ' . $instruction . "<br/>";
           
$msg .= '============================' . "<br/>";
            echo
$msg;

           
$postId = explode('/', $media->getLink());

            if (!
$checkPost->postIsExisted($postId[4])) {
               
SendMail::sendMail($msg, $media, $feed->getUserName());
               
$checkPost->insertPostId($postId[4]);
            }

            break;
        }

       
$msg = wordwrap($msg, 70);

       
// Second Page

       
$api->setEndCursor($feed->getEndCursor());

       
sleep(1); // avoir 429 Rate limit from Instagram

       
$feed = $api->getFeed();

        echo
"<br/><br/>";
        echo
'============================' . "<br/>";
        echo
'Medias second page : ' . "<br/>";
        echo
'============================' . "<br/><br/>";

       
/** @var \Instagram\Hydrator\Component\Media $media */
       
foreach ($feed->getMedias() as $media) {
            echo
'ID : ' . $media->getId() . "<br/>";
            echo
'Caption : ' . $media->getCaption() . "<br/>";
            echo
'Link : ' . $media->getLink() . "<br/>";
            echo
'Instructions: ' . $instruction . "<br/>";
            echo
'============================' . "<br/>";
        }

       
// And etc...

   
} catch (\Instagram\Exception\InstagramException $exception) {
       
var_dump($exception->getMessage());
    }
}


  Files folder image Files  
File Role Description
Accessible without login Plain text file index.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:47
This week:0
All time:10,584
This week:125Up