【发布时间】:2015-02-18 11:56:05
【问题描述】:
环境:在 Windows Server 2008 上运行的 ASP.NET 4.0 窗体 Visual Studio 2010 终极版 DotNetOpenAuth(刚学习)
尝试做一些非常简单的事情,使用 Vimeo 作为主机创建一个视频存档,但我们希望它们在 Vimeo 上,只是嵌入到我们的网站上。我们上传了一些示例视频,并将它们设置为隐藏并限制嵌入到我们的域中。测试时,它们嵌入得很好,但是当我们发送视频信息请求(http://vimeo.com/api/v2/video/*.xml)时,服务器响应 404 not found。如果我们返回并将其设置为任何人都可以查看,我们会得到我们需要的响应信息。我们如何才能获取视频信息并仍然隐藏视频?
private string GetVideoXML(string id)
{
try
{
// URL
String url = string.Format("http://vimeo.com/api/v2/video/{0}.xml", id);
// Make the request
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
string token = "<My authorization token from Vimeo API>";
request.Headers.Add("Authorization", "Basic " + token);
// Show me the money?
WebResponse response = request.GetResponse(); // Throws an exception, 404 not found
// Read XML
StreamReader reader = new StreamReader(response.GetResponseStream());
String responseData = reader.ReadToEnd();
//Close
reader.Close();
response.Close();
// Show me the money!
return responseData;
}
catch (Exception ex)
{
// You has some 'splaining to do
litError.Text = ex.ToString();
}
}
【问题讨论】:
标签: asp.net dotnetopenauth vimeo vimeo-api