如何从flickr API获取正确的JSON对象 [英] how to get correct JSON object from flickr API

查看:93
本文介绍了如何从flickr API获取正确的JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用flickr照片搜索方法来检索公共照片。
当我用jquery运行它时,它工作正常,我得到正确形式的json对象。

I used flickr photo search method to retrieve public photos. when I run it with jquery, it works fine, I get the json object in correct form.

{
    "photos": {
        "photo": [
            {
              .........
            }
        ]
    },
    "stat": "ok"
}

但是当我使用时它使用AngularJs,我得到了带有前缀的相同对象jsonFlickrApi

But when I use it with AngularJs, I got the same object with a prefix jsonFlickrApi

jsonFlickrApi({
    "photos": {
        "photo": [
            {
               ...... 
            }
        ]
    },
    "stat": "ok"
})

我在AngularJs中使用的是:

what I used in AngularJs is:

myApp.service('dataService', function($http) {
    delete $http.defaults.headers.common['X-Requested-With'];
    this.flickrPhotoSearch = function() {
        return $http({
            method: 'GET',
            url: 'https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=3f807259749363aaa29c2fa93945&tags=india&format=json&callback=?',
            dataType: 'json'
         });
     }
});

请告诉我如何将第二个JSON转换为第一个JSON。
我可以在 $ http 调用或必须改变JSON对象。

Please tell me how can I convert the second JSON to the first one. Is there anything I can do in $http call or have to alter JSON object.

推荐答案

网址存在问题。
此Url适用于我。

There was problem in the url. This Url works for me.

https://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=3f807259749363aaa29c712fa93945&user_id=61495424@N00&format=json&nojsoncallback=?

这篇关于如何从flickr API获取正确的JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆