1

我试图显示一组在特定时间和给定纬度和经度内的图像。Instagram API 脚本在控制台日志中收到错误消息。这是错误:

SyntaxError:意外的令牌':'

这是代码:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

<script>

$(document).ready(function() {

      var count = "20";

      var access_token = "5567117.f59def8.65c6953a15e94932a44f9b4311aa8653";

      var access_parameters = {access_token:access_token};

      function grabImages(access_parameters) {

            var instagramUrl =  "https://api.instagram.com/v1/media/search?lat=54.963782&lng=-1.623423&max_timestamp=1354950000&min_timestamp=1354935600&distance=2000?callback=?&count=" + count;


            $.getJSON(instagramUrl, access_parameters, onDataLoaded);

            console.log(instagramUrl);

      }

      function onDataLoaded(instagram_data) {

          if(instagram_data.meta.code == 200) {

            var photos = instagram_data.data;

            if(photos.length > 0) {

              for (var key in photos) {
              var photo = photos[key];
              $("#target").append('<img src ="' + photo.images.thumbnail.url + '">');
              $("#target").append('<span>' + photo.user.username +'</span>');
              }

            } else {
              $("#target").append("Hmm.  I couldn’t find anything!");
            }

          } else {

              var error = data.meta.error_message;
              $("#target").append('Something happened, Instagram said: ' + error);
          }

          }

          grabImages(access_parameters);

  });

</script>
4

1 回答 1

0

?您的查询字符串在回调参数之前有一个额外的。

"https://api.instagram.com/v1/media/search?lat=54.963782&lng=-1.623423&max_timestamp=1354950000&min_timestamp=1354935600&distance=2000?callback=?&count="

应该

"https://api.instagram.com/v1/media/search?lat=54.963782&lng=-1.623423&max_timestamp=1354950000&min_timestamp=1354935600&distance=2000&callback=?&count="

于 2013-01-15T18:49:59.187 回答