问题描述
我尝试为自己制作一个小型应用程序,但我发现了这个应用程序如何使用C#在Dailymotion上上传视频?有人有完整的代码吗?
I try to make small application for myself and I found this applicationHow to upload video on Dailymotion with c# ?? Is somebody has a complete code?
当我尝试所有操作但发布不起作用时.我使用了提琴手,但我找不到错误.这是代码
When I tried every thing but publishing is not working. I used fiddler but I cant find the error.Here is the code
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()时,将给出错误.那么,这里出了什么问题??
When it reaches request.GetResponse() it gives the error. So what is the problem here..?
推荐答案
我相信您在使用OAuth而不是基本身份验证时需要摆脱url中的我",
I believe you need to get rid of the "me" in the url as you're using OAuth instead of basic authentication, like this:
"https://api.dailymotion.com/videos?url="
代替:
"https://api.dailymotion.com/me/videos?url="
至少在一个看起来像这样的快速扫描中,一年前,我为一个客户端编写了一个自动发布器,它没有在URL中使用 me
.我的凭据现在无效,因此无法对其进行测试.您链接的答案中似乎有一个错误.
At least in a quick scan that looks like it's it, I wrote an auto-publisher for a client a year ago and it didn't use the me
in the url. My credentials are invalid now, so can't test it unfortunately. It seems to be a bug in the answer you linked.
如果您能阅读其他语言,我发现遍历他们的SDK并转换代码会很有帮助:
If you can read other languages, I found it helpful just going through their SDKs and converting the code:
http://www.dailymotion.com/doc/api/sdk-php.html
https://github.com/dailymotion/dailymotion-sdk-php/blob/master/Dailymotion.php
这篇关于远程服务器返回错误:(403)禁止.在发帖期间...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!