Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 49 | | All time: 10,716 This week: 560 |
|
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
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 |
| |
|
|
Innovation award
Nominee: 16x
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());
}
}
|
Details
ig-feed-notification
Introduction
This is the simple web service and it can send the latest Instagram feed with specific user via SMTP server.
Requirements
-
php>=5.6
-
Composer
-
SMTP server
-
MySQL/MariaDB
Usage
git clone https://github.com/peter279k/ig-feed-notification
-
Download composer and install the required dependencies.
php composer.phar install -n
-
Copy the `.env.example` to `.env` and set the DB host, driver, database name, user name, user password, mail host, user name and password.
cp .env.example .env
-
Copy the `phinx.yml.example` to `phinx.yml` and remember to set the database name, user name and password in the production block.
cp phinx.yml.example phinx.yml
-
Execute the database migration in the project root path.
php vendor/bin/phinx migrate
-
Visit the `index.php` via the web browser.
http://host-name-or-ip-address/ig-feed-notification/index.php
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.