@
@
@atambalasi2016-06-07 13:30:03
PHP
@atambalasi, 2016-06-07 13:30:03

How to save image meta data from Instagram API?

I get a list of images by tag from Instagram.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.instagram.com/v1/tags/My_tages_here/media/recent?access_token=YOUR_TOKEN&count=20"); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    $output = curl_exec($ch); 
$jsonData = json_decode($output);
curl_close($ch);

Output on display
$tags = "";
            for($j=0; $j<count($jsonData->data[0]->tags); $j++)
            {
              if($j!=0) $tags .= ", ";													
              $tags .= "#".$jsonData->data[0]->tags[$j];

            }
                        for($j=0; $j<count($jsonData->data); $j++){
                            if(!empty($jsonData->data[$j]->images->standard_resolution->url)){
       
     
                            echo '<div class="cls_img">
                                    <a href="'.$jsonData->data[$j]->link .'"  target="_blank">
                                          <div class="img">

                                                <img src="'. $jsonData->data[$j]->images->standard_resolution->url .'"> 
                                                

                                            </div>	
                                      <div class="info" id="heading0">
                                          <h3>
                                            ' . $tags .'
                                          </h3>
                                          <p>'. $jsonData->data[$j]->caption->text.'</p>
                                      </div>
                                  </a>
                                </div>';
                                
                            
                                }
                        }

How to implement such functionality. From the list of images, save to the database only those that the user has selected. That is, you need to save the link, description, and tags for the photo.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Greg Popov, 2016-06-07
@Gregpopov

Check what is saved by the user and just insert into the database, of course you don’t need to shove the photo there, it will go to the folder, but the link to the photo (on your resource) will go to the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question