Skip to content

Instantly share code, notes, and snippets.

@cosenary cosenary/index.php
Last active Jun 14, 2019

Embed
What would you like to do?
Instagram PHP API - Likes
<?php
require 'Instagram.php';
use MetzWeb\Instagram\Instagram;
$instagram = new Instagram(array(
'apiKey' => 'YOUR_APP_KEY',
'apiSecret' => 'YOUR_APP_SECRET',
'apiCallback' => 'YOUR_APP_CALLBACK'
));
$token = 'USER_ACCESS_TOKEN';
$instagram->setAccessToken($token);
$id = 'MEDIA_ID';
$result = $instagram->likeMedia($id);
if ($result->meta->code === 200) {
echo 'Success! The image was added to your likes.';
} else {
echo 'Something went wrong :(';
}
@umutc

This comment has been minimized.

Copy link

commented May 1, 2015

hi,

could you give me an "MEDIA_ID" example please because i saw many id's in "$photos = $instagram->getTagMedia('istanbul',100);". for example first iteration of this response :

              stdClass Object

(
[attribution] =>
[videos] => stdClass Object
(
[low_bandwidth] => stdClass Object
(
[url] => https://scontent.cdninstagram.com/hphotos-xpf1/l/t50.2886-16/11199317_914648191918614_1811524043_s.mp4
[width] => 480
[height] => 480
)

        [standard_resolution] => stdClass Object
            (
                [url] => https://scontent.cdninstagram.com/hphotos-xaf1/t50.2886-16/11213122_698655500243540_1463163823_n.mp4
                [width] => 640
                [height] => 640
            )

        [low_resolution] => stdClass Object
            (
                [url] => https://scontent.cdninstagram.com/hphotos-xpf1/l/t50.2886-16/11199317_914648191918614_1811524043_s.mp4
                [width] => 480
                [height] => 480
            )

    )

[tags] => Array
    (
        [0] => world
        [1] => türkiye
        [2] => istanbul
        [3] => sarıyer
    )

[location] => 
[comments] => stdClass Object
    (
        [count] => 0
        [data] => Array
            (
            )

    )

[filter] => Normal
[created_time] => 1430501547
[link] => https://instagram.com/p/2JdaMoHsJr/
[likes] => stdClass Object
    (
        [count] => 0
        [data] => Array
            (
            )

    )

[images] => stdClass Object
    (
        [low_resolution] => stdClass Object
            (
                [url] => https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s306x306/e15/11176169_815002501921158_583498260_n.jpg
                [width] => 306
                [height] => 306
            )

        [thumbnail] => stdClass Object
            (
                [url] => https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s150x150/e15/11176169_815002501921158_583498260_n.jpg
                [width] => 150
                [height] => 150
            )

        [standard_resolution] => stdClass Object
            (
                [url] => https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/e15/11176169_815002501921158_583498260_n.jpg
                [width] => 640
                [height] => 640
            )

    )

[users_in_photo] => Array
    (
    )

[caption] => stdClass Object
    (
        [created_time] => 1430501547
        [text] => #Sarıyer#İstanbul#Türkiye#World •

Martı
[from] => stdClass Object
(
[username] => mstdgr
[profile_picture] => https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/11142802_952015994829938_1172025133_a.jpg
[id] => 243281967
[full_name] => -Broker-
)

        [id] => 975440139962466324
    )

[type] => video
[id] => 975440137915646571_243281967
[user] => stdClass Object
    (
        [username] => mstdgr
        [profile_picture] => https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/11142802_952015994829938_1172025133_a.jpg
        [id] => 243281967
        [full_name] => -Broker-
    )

)

@sanjeetbisht

This comment has been minimized.

Copy link

commented Aug 30, 2015

[id] => 975440137915646571_243281967

this is your id @umutc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.