Guest User

Untitled

a guest
Jan 1st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.66 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8">
  5.         <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.         <title>Instagram Test</title>
  7.         <meta name="description" content="">
  8.         <meta name="viewport" content="width=device-width, initial-scale=1">
  9.         <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
  10.         <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  11.         <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
  12.        
  13.     </head>
  14.     <body>
  15.         <!--[if lt IE 8]>
  16.            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  17.        <![endif]-->
  18.  
  19.         <!-- Add your site or application content here -->
  20.        
  21.         <div class="container">
  22.               <div class="row results">
  23.               </div>
  24.         </div>
  25.        
  26.         <!-- Modal -->
  27.           <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  28.             <div class="modal-dialog">
  29.               <div class="modal-content">
  30.                 <div class="modal-header">
  31.                   <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  32.                   <h4 class="modal-title">Modal title</h4>
  33.                 </div>
  34.                 <div class="modal-body">
  35.                     <img class="img-responsive"src="' + gram.images.standard_resolution.url + '" alt="image" />
  36.                 </div>
  37.                 <div class="modal-footer">
  38.                  
  39.                 </div>
  40.               </div><!-- /.modal-content -->
  41.             </div><!-- /.modal-dialog -->
  42.           </div><!-- /.modal -->
  43.  
  44.        
  45.    
  46.         <script>
  47.              $(function () {
  48.  
  49.                // Adding the above wrapper around all the code makes sure the whole
  50.                // DOM is loaded before any code is actually run. Its a good practice
  51.                // read about it here: http://api.jquery.com/ready/
  52.  
  53.                var client_id = '[client_id]'
  54.                var apiUrl = "https://api.instagram.com/v1/users/self/feed?access_token=[access_token]&callback=?"
  55.  
  56.                function success (instagramData) {
  57.                  // This is run if the ajax call is successful
  58.                  // The "instagramData" being passed to this function is the returned data from the url
  59.  
  60.                  if (instagramData.meta.code != 200) {
  61.                    // If we don't get a 200 that means instagram threw an error.
  62.                    // Instead of adding the html for images to .results div, we will put the error in there so
  63.                    // we know what happend
  64.                    $('.results').html('<h1>An Error Occured</h1><p>' + instagramData.meta.error_message + '</p>');
  65.                    return
  66.                  }
  67.  
  68.                  $.each(instagramData.data, function(index, gram) {
  69.                    // instagramData.data is the "data" inside the returned json. There is "meta" and "data".
  70.                    // index is just an incremental number for each gram. we don't need it yet.
  71.                    // gram is the information for EACH gram. this $.each loops over all of them.
  72.  
  73.                    if (gram.type == 'image') {
  74.                      // for this example we only care about images
  75.                      $('.results').append('<div class="col-md-3">' +
  76.                                           '<p><img class="img-circle" style="margin-right: 5px" width="60" src="' + gram.user.profile_picture + '">' + gram.user.username + '</p>' +
  77.                                           '<a href="#myModal" data-toggle="modal" data-img-url="' + gram.images.standard_resolution.url + '"><img class="img-thumbnail" src="' + gram.images.low_resolution.url + '"/></a>' +
  78.                                           '</div>')
  79.                    }
  80.                    if (gram.type == 'video') {
  81.                      // for this example we only care about videos
  82.                      $('.results').append('<div class="col-md-3">' +
  83.                                           '<p><img class="img-circle" style="margin-right: 5px" width="60" src="' + gram.user.profile_picture + '">' + gram.user.username + '</p>' +
  84.                                           '<a href="#myModal" data-toggle="modal" data-img-url="' + gram.videos.standard_resolution.url +'">href="' + gram.videos.standard_resolution.url +'"><video class="img-thumbnail" src="' + gram.videos.low_resolution.url + '"/></a>' +
  85.                                           '</div>')
  86.                    }
  87.                  });
  88.                }
  89.  
  90.                $.ajax({
  91.                  type: "GET",
  92.                  url: apiUrl,
  93.                  dataType: "json",
  94.                  success: success // If successful we call the success function, which lives up above
  95.                });
  96.              });
  97.         </script>
  98.  
  99.     </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment