The Movie Database 支持

Hi,

Probably a dumb question but I'll ask anyway as I can't get it to work... how can I add or remove an item from the watchlist using the raw data method. I've tried all sorts of combinations, read and re-read the documentation and Googled for answers but not had any luck yet.

https://api.themoviedb.org/3/account/{id}/watchlist?api_key=XXXX&session_id=XXXX{"media_type": "movie","media_id": 127585,"watchlist": false}

Any help or a working example would be gratefully appreciated.

Thanks

7 回复(第 1 页,共 1 页)

Jump to last post

No one gonna throw me a bone :(

Hey Ben,

You need to POST the data in as JSON. In cURL, an working example looks like:

curl -H "Accept: application/json" -H "Content-Type: application/json" \
-d "{'media_type': 'movie', 'media_id': 550, 'watchlist': true}" \
"https://api.themoviedb.org/3/account/{ID}/watchlist?api_key=###&session_id=###"

Hi Travis,

Thanks for the reply... I still don't get it but I'll go read up and see if I can learn more.

Thanks

What language are you coding in?

VB.NET, I tried the example but it doesn't work for me. Not had time this week to find out why.

The error I get is: The 'Accept' header must be modified using the appropriate property or method.

And the code I'm using looks like:

Dim request = TryCast(System.Net.WebRequest.Create("https://api.themoviedb.org/3/account/{id}/watchlist?api_key=xxxx&session_id=xxxx"), System.Net.HttpWebRequest)
request.Method = "POST"
request.ContentType = "application/json"
request.Headers.Add("Content-Type", "application/json")
request.Headers.Add("Accept", "application/json")
Using writer = New System.IO.StreamWriter(request.GetRequestStream())
  Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("{\n    \""media_type\"": \""movie\"",\n    \""media_id\"": 11,\n    \""watchlist\"": true\n}")
  request.ContentLength = byteArray.Length
  writer.Write(byteArray)
  writer.Close()
End Using
Dim responseContent As String
Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse)
  Using reader = New System.IO.StreamReader(response.GetResponseStream())
    responseContent = reader.ReadToEnd()
  End Using
End Using

I got it sorted in the end... just for future reference or anyone else who needs a nudge in the right direction I've added my code below.


        Dim apiKey As String = "XXX"
        Dim sessionID As String = "XXX"
        Dim jsonEncoding As String = "{" & vbLf & "    ""media_type"": ""movie""," & vbLf & "    ""media_id"": 127585," & vbLf & "    ""watchlist"": true" & vbLf & "}"

        Try

            Dim client As New Net.WebClient
            client.Headers.Add("Content-Type", "application/json")
            client.Headers.Add("Accept", "application/json")

            Dim responsebytes = client.UploadData("https://api.themoviedb.org/3/account/{id}/watchlist?api_key=" & apiKey & "&session_id=" & sessionID, _
            "POST", System.Text.Encoding.UTF8.GetBytes(jsonEncoding))

        Catch webex As WebException
            MsgBox(webex.Message)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Thanks

Ben

找不到电影或节目?登录并创建它吧。

全站通用

s 聚焦到搜索栏
p 打开个人资料菜单
esc 关闭打开的窗口
? 打开键盘快捷键窗口

在媒体页面

b 返回(或返回上级)
e 进入编辑页面

在电视季页面

(右箭头)下一季
(左箭头)前一季

在电视集页面

(右箭头)下一集
(左箭头)上一集

在所有图像页面

a 打开添加图片窗口

在所有编辑页面

t 打开翻译选择器
ctrl+ s 提交

在讨论页面

n 创建新讨论
w 切换关注状态
p 设为公开 / 私密讨论
c 关闭 / 开放讨论
a 打开活动页
r 回复讨论
l 跳转至最新回复
ctrl+ enter 发送信息
(右箭头)下一页
(左箭头)前一页

设置

想给这个条目评分或将其添加到片单中?

登录

还不是会员?

注册加入社区