-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathcheckpoint-challenge.php
44 lines (35 loc) · 1.78 KB
/
checkpoint-challenge.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
use Instagram\Api;
use Instagram\Auth\Checkpoint\ImapClient;
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);
$imapClient = new ImapClient($credentials->getImapServer(), $credentials->getImapLogin(), $credentials->getImapPassword());
$api->login($credentials->getLogin(), $credentials->getPassword(), $imapClient);
$profile = $api->getProfile('robertdowneyjr');
echo '============================' . "\n";
echo 'User Information : ' . "\n";
echo '============================' . "\n";
echo 'ID : ' . $profile->getId() . "\n";
echo 'Full Name : ' . $profile->getFullName() . "\n";
echo 'UserName : ' . $profile->getUserName() . "\n";
echo 'Following : ' . $profile->getFollowing() . "\n";
echo 'Followers : ' . $profile->getFollowers() . "\n";
echo 'Biography : ' . $profile->getBiography() . "\n";
echo 'External Url : ' . $profile->getExternalUrl() . "\n";
echo 'Profile Picture : ' . $profile->getProfilePicture() . "\n";
echo 'Verified Account : ' . ($profile->isVerified() ? 'Yes' : 'No') . "\n";
echo 'Private Account : ' . ($profile->isPrivate() ? 'Yes' : 'No') . "\n";
echo 'Medias Count : ' . $profile->getMediaCount() . "\n";
echo '============================' . "\n";
} catch (InstagramException $e) {
print_r($e->getMessage());
} catch (CacheException $e) {
print_r($e->getMessage());
}