[英]how to catch the exception for “The remote server returned an error: (403) Forbidden.”
[英]The remote server returned an error: (403) Forbidden. during post request…?
我尝试为自己制作一个小型应用程序,但我找到了该应用程序。 如何使用c#在Dailymotion上上传视频? 有人有完整的代码吗?
当我尝试所有操作但发布不起作用时。 我使用了提琴手,但我找不到错误。 这是代码
var request = WebRequest.Create("https://api.dailymotion.com/me/videos?url=" + Uri.EscapeUriString(uploadResponse.url));
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Headers.Add("Authorization", "OAuth " + accessToken);
var requestBytes = Encoding.UTF8.GetBytes("title=test 123&channel=Funny&tags=Humor&description=Testing testing&published=true");
var requestBytes = Encoding.UTF8.GetBytes(requestString);
var requestStream = request.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
var response = request.GetResponse();
var responseStream = response.GetResponseStream();
string responseString;
using (var reader = new StreamReader(responseStream))
{
responseString = reader.ReadToEnd();
}
当到达request.GetResponse()时,将给出错误。 那么这里是什么问题呢?
我相信您在使用OAuth而不是基本身份验证时需要摆脱url中的“我”,例如:
"https://api.dailymotion.com/videos?url="
代替:
"https://api.dailymotion.com/me/videos?url="
至少在一个看起来像这样的快速扫描中,我在一年前为客户编写了一个自动发布器,但它没有在网址中使用me
。 我的凭据现在无效,因此无法对其进行测试。 您所连结的答案似乎有错误。
如果您能阅读其他语言,我发现仅浏览他们的SDK并转换代码会有所帮助:
http://www.dailymotion.com/doc/api/sdk-php.html
https://github.com/dailymotion/dailymotion-sdk-php/blob/master/Dailymotion.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.