-
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathpost-comment.php
More file actions
28 lines (20 loc) · 799 Bytes
/
post-comment.php
File metadata and controls
28 lines (20 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
declare(strict_types=1);
use Instagram\Api;
use Instagram\Exception\InstagramException;
use Psr\Cache\CacheException;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
require realpath(dirname(__FILE__)) . '/../vendor/autoload.php';
$credentials = include_once realpath(dirname(__FILE__)) . '/credentials.php';
$cachePool = new FilesystemAdapter('Instagram', 0, __DIR__ . '/../cache');
try {
$api = new Api($cachePool);
$api->login($credentials->getLogin(), $credentials->getPassword());
// 2657627124756968810 is id of https://www.instagram.com/p/CThycoMlPVq/
$postId = 2657627124756968810;
$api->commentPost($postId, 'Awesome!');
} catch (InstagramException $e) {
print_r($e->getMessage());
} catch (CacheException $e) {
print_r($e->getMessage());
}