首页 文章

无法使用字段参数在vimeo api GET调用中过滤结果

提问于
浏览
1

我正在使用Vimeo API,同时拨打电话访问我正在进行的用户视频

https://api.vimeo.com/users/61402929/videos?access_token=token

这是返回一个json响应

{
    "total": 1,
    "page": 1,
    "per_page": 25,
    "paging": {
        "next": null,
        "previous": null,
        "first": "/users/61402929/videos?access_token=365879aad6244864dab70902890fc1a1&page=1",
        "last": "/users/61402929/videos?access_token=365879aad6244864dab70902890fc1a1&page=1"
    },
    "data": [
        {
            "uri": "/videos/200383630",
            "name": "Bhuvan bam _ Bb ki vines _ playing piano _ Saagar jaisi aankhon waali  _ bhuvan bam  live (360p_30fps_H264-96kbit_AAC)",
            "description": "BB Ki Vines",
            "link": "https://vimeo.com/200383630",
            "duration": 59,
            "width": 320,
            "language": null,
            "height": 320,
            "embed": {
                "uri": null,
                "html": "<iframe src=\"https://player.vimeo.com/video/200383630?badge=0&autopause=0&player_id=0\" width=\"320\" height=\"320\" frameborder=\"0\" title=\"Bhuvan bam _ Bb ki vines _ playing piano _ Saagar jaisi aankhon waali  _ bhuvan bam  live (360p_30fps_H264-96kbit_AAC)\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>",
                "buttons": {
                    "like": true,
                    "watchlater": true,
                    "share": true,
                    "embed": true,
                    "hd": false,
                    "fullscreen": true,
                    "scaling": true
                },
                "logos": {
                    "vimeo": true,
                    "custom": {
                        "active": false,
                        "link": null,
                        "sticky": false
                    }
                },
                "title": {
                    "name": "user",
                    "owner": "user",
                    "portrait": "user"
                },
                "playbar": true,
                "volume": true,
                "color": "00adef"
            },
            "created_time": "2017-01-20T17:57:04+00:00",
            "modified_time": "2017-01-20T17:58:41+00:00",
            "release_time": "2017-01-20T17:57:04+00:00",
            "content_rating": [
                "unrated"
            ],
            "license": null,
            "privacy": {
                "view": "anybody",
                "embed": "public",
                "download": true,
                "add": true,
                "comments": "anybody"
            },
            "pictures": {
                "uri": "/videos/200383630/pictures/613872508",
                "active": true,
                "type": "custom",
                "sizes": [
                    {
                        "width": 100,
                        "height": 75,
                        "link": "https://i.vimeocdn.com/video/613872508_100x75.webp?r=pad",
                        "link_with_play_button": "https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F613872508_100x75.webp&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"
                    },
                    {
                        "width": 200,
                        "height": 150,
                        "link": "https://i.vimeocdn.com/video/613872508_200x150.webp?r=pad",
                        "link_with_play_button": "https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F613872508_200x150.webp&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"
                    },
                    {
                        "width": 295,
                        "height": 166,
                        "link": "https://i.vimeocdn.com/video/613872508_295x166.webp?r=pad",
                        "link_with_play_button": "https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F613872508_295x166.webp&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"
                    },
                    {
                        "width": 640,
                        "height": 640,
                        "link": "https://i.vimeocdn.com/video/613872508_640x640.webp?r=pad",
                        "link_with_play_button": "https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F613872508_640x640.webp&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"
                    },
                    {
                        "width": 960,
                        "height": 960,
                        "link": "https://i.vimeocdn.com/video/613872508_960x960.webp?r=pad",
                        "link_with_play_button": "https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F613872508_960x960.webp&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png"
                    }
                ],
                "resource_key": "fdb74e1e2dcaf7c929cfe14240765f45f2d2a302"
            },
            "tags": [],
            "stats": {
                "plays": 0
            },
            "metadata": {
                "connections": {
                    "comments": {
                        "uri": "/videos/200383630/comments",
                        "options": [
                            "GET",
                            "POST"
                        ],
                        "total": 0
                    },
                    "credits": {
                        "uri": "/videos/200383630/credits",
                        "options": [
                            "GET",
                            "POST"
                        ],
                        "total": 1
                    },
                    "likes": {
                        "uri": "/videos/200383630/likes",
                        "options": [
                            "GET"
                        ],
                        "total": 0
                    },
                    "pictures": {
                        "uri": "/videos/200383630/pictures",
                        "options": [
                            "GET",
                            "POST"
                        ],
                        "total": 1
                    },
                    "texttracks": {
                        "uri": "/videos/200383630/texttracks",
                        "options": [
                            "GET",
                            "POST"
                        ],
                        "total": 0
                    },
                    "related": null
                },
                "interactions": {
                    "watchlater": {
                        "added": false,
                        "added_time": null,
                        "uri": "/users/61402929/watchlater/200383630"
                    }
                }
            },
            "user": {
                "uri": "/users/61402929",
                "name": "Rishabh Kumar",
                "link": "https://vimeo.com/user61402929",
                "location": null,
                "bio": null,
                "created_time": "2017-01-11T16:15:43+00:00",
                "account": "basic",
                "pictures": null,
                "websites": [],
                "metadata": {
                    "connections": {
                        "activities": {
                            "uri": "/users/61402929/activities",
                            "options": [
                                "GET"
                            ]
                        },
                        "albums": {
                            "uri": "/users/61402929/albums",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "appearances": {
                            "uri": "/users/61402929/appearances",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "categories": {
                            "uri": "/users/61402929/categories",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "channels": {
                            "uri": "/users/61402929/channels",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "feed": {
                            "uri": "/users/61402929/feed",
                            "options": [
                                "GET"
                            ]
                        },
                        "followers": {
                            "uri": "/users/61402929/followers",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "following": {
                            "uri": "/users/61402929/following",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "groups": {
                            "uri": "/users/61402929/groups",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "likes": {
                            "uri": "/users/61402929/likes",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "moderated_channels": {
                            "uri": "/users/61402929/channels?filter=moderated",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "portfolios": {
                            "uri": "/users/61402929/portfolios",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "videos": {
                            "uri": "/users/61402929/videos",
                            "options": [
                                "GET"
                            ],
                            "total": 1
                        },
                        "watchlater": {
                            "uri": "/users/61402929/watchlater",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "shared": {
                            "uri": "/users/61402929/shared/videos",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        },
                        "pictures": {
                            "uri": "/users/61402929/pictures",
                            "options": [
                                "GET",
                                "POST"
                            ],
                            "total": 0
                        },
                        "watched_videos": {
                            "uri": "/me/watched/videos",
                            "options": [
                                "GET"
                            ],
                            "total": 0
                        }
                    }
                },
                "preferences": {
                    "videos": {
                        "privacy": "anybody"
                    }
                },
                "content_filter": [
                    "language",
                    "drugs",
                    "violence",
                    "nudity",
                    "safe",
                    "unrated"
                ],
                "resource_key": "6fe192b4cb782d1341fbf3fb3d0ba04a0295236d"
            },
            "app": null,
            "status": "available",
            "resource_key": "cad1f2b7d388491329363a4936f0219fa4dfd18b",
            "embed_presets": null
        }
    ]
}

但是我只对字段分页,总数和数据数组的某些字段感兴趣,因此我使用过滤器如下所示

https://api.vimeo.com/users/61402929/videos?access_token=token&fields=paging,data.name,data.description,data.link,data.pictures.sizes.link

但上述电话的响应是

{
"total": 1,
"page": 1,
"per_page": 25,
"paging": {
    "next": null,
    "previous": null,
    "first": "/users/61402929/videos?access_token=365879********0902890fc1a1&fields=paging%2Cdata.name%2Cdata.description%2Cdata.link%2Cdata.pictures.sizes.link&page=1",
    "last": "/users/61402929/videos?access_token=365879********0902890fc1a1&fields=paging%2Cdata.name%2Cdata.description%2Cdata.link%2Cdata.pictures.sizes.link&page=1"
},
"data": [
    []
]

}

编辑:也是呼叫的响应

https://api.vimeo.com/users/61402929/videos?access_token=token&fields=paging

{
"total": 1,
"page": 1,
"per_page": 25,
"paging": {
    "next": null,
    "previous": null,
    "first": "/users/61402929/videos?access_token=365879*********70902890fc1a1&fields=paging&page=1",
    "last": "/users/61402929/videos?access_token=365879*********70902890fc1a1&fields=paging&page=1"
},
"data": [
    []
]

}

我无法弄清楚为什么请求没有得到正确处理 .

1 回答

  • 3

    一些事情:首先,访问令牌应该在请求的auth头中传递,而不是在你提到的请求uri中传递:https://developer.vimeo.com/api/authentication#making-requests

    关于字段过滤器,过滤器仅适用于嵌套在 data 下的键 . 对于返回多个项目的请求,始终返回 paging 数组 .

    所以你的示例请求应如下所示:

    https://api.vimeo.com/users/61402929/videos?fields=name,description,link,pictures.sizes.link
    

    更多信息:https://developer.vimeo.com/api/spec#json-filter

    希望这可以帮助!

相关问题