Пример #1
0
 function printImages($user_id, $access_token)
 {
     $url = 'https://api.instagram.com/v1/users/' . $user_id . '/media/recent?access_token=' . $access_token . '&count=-1';
     $instagramInfo = connectToInstagram($url);
     $results = json_decode($instagramInfo, true);
     //go through images and print each one
     foreach ($results['data'] as $items) {
         $image_url = $items['images']['low_resolution']['url'];
         echo "<div class='col-sm-6 col-md-4'>";
         echo "<div class='thumbnail'>";
         echo "<img src='" . $image_url . "' alt='' />";
         echo "<div class='caption'>";
         $likes = $items['likes']['count'];
         $comments = $items['comments']['count'];
         $lat = $items['location']['latitude'];
         $long = $items['location']['longitude'];
         if ($lat != null) {
             echo "<h4><a href='http://maps.google.com/?q=" . $lat . "," . $long . "' target='_blank'><span class='glyphicon glyphicon-map-marker'></span>Show in map</a></h4>";
         } else {
             echo "<h5>Map info not found</h5>";
         }
         echo "<span class='glyphicon glyphicon-heart' aria-hidden='true'</span>" . $likes . " ";
         echo "<span class='glyphicon glyphicon-comment' aria-hidden='true'</span>" . $comments;
         echo "</div>";
         echo "</div>";
         echo "</div>";
     }
 }
Пример #2
0
function getHashTag()
{
    $url2 = 'https://api.instagram.com/v1/tags/capitalone/media/recent?access_token=' . access_token . '&count=50';
    $instagramInfo = connectToInstagram($url2);
    $results = json_decode($instagramInfo, true);
    foreach ($results['data'] as $value) {
        $userId = $value['caption']['from']['id'];
        $caption = $value['caption']['text'];
        $likes = $value['likes']['count'];
        echo "User Name: " . $value['user']['username'] . '</br>';
        echo "Full Name: " . $value['user']['full_name'] . '</br>';
        echo "Follows: " . getFollowedBy($userId) . '</br>';
        echo "Followed By: " . getFollows($userId) . '</br>';
        echo "Caption: " . $value['caption']['text'] . '</br>';
        echo "Likes: " . $likes . '</br></br>';
        $likes = $value['likes']['count'];
        if ($likes == 0) {
            echo "Post Rating: Negative :(" . '</br>';
            //Thinking most will not give likes to a negative post
        } elseif ($likes > 0 && $likes <= 30) {
            echo "Post Rating: Neutral" . '</br>';
        } else {
            echo "Post Rating: Positive" . '</br>';
        }
    }
}
Пример #3
0
function printImages($userID,$accessToken){
	$url = 'https://api.instagram.com/v1/users/'. $userID .'/media/recent?access_token='. $accessToken .'&count=5';
	$instagramInfo = connectToInstagram($url);
	$results = json_decode($instagramInfo, true);

	//parse through results
	foreach($results['data'] as $item){
		$image_url = $item['images']['low_resolution']['url'];
		echo '<img src="'.$image_url.'" /> <br/>';
		// savePicture($image_url);
	}
}
Пример #4
0
function printTagImages($tag)
{
    $url = 'https://api.instagram.com/v1/tags/' . $tag . '/media/recent?client_id=' . clientID . '&count=30';
    $instagramInfo = connectToInstagram($url);
    $results = json_decode($instagramInfo, true);
    foreach ($results['data'] as $items) {
        $image_url = $items['images']['low_resolution']['url'];
        $comments = $items['comments'];
        $ileti = $items['caption']['text'];
        $username = $items['caption']['from']['username'];
        echo $items['user']['username'] . '</br>';
        echo '<img src="' . $image_url . '"/></br>';
        echo '<b>' . $username . '</b>:  ' . $ileti . '</br>';
        foreach ($comments['data'] as $commit) {
            echo '<b>' . $commit['from']['username'] . '</b>:  ' . $commit['text'] . '</br>';
        }
        echo '</br>';
    }
}