我想发送一个HTTP POST请求中的视频url,但它不适合我,我想我已经(几乎?)必要的代码,使其工作,否则我错过了很简单的事情?在Android应用程序没有数据的HTTP POST
public void postVideoURL() throws IOException {
String encodedUrl = URLEncoder.encode("http://video.ted.com/talks/podcast/DavidBrooks_2011.mp4", "UTF-8");
URL obj = new URL("http://10.50.0.105:8060/launch/dev?url="+encodedUrl);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//add request header
con.setRequestMethod("POST");
// Send post request
con.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
wr.flush();
wr.close();
wr.write("");
}
任何提示,让我走向正确的方向?
这里是我想要做的,但在C#
using System.Net;
using System.Web;
class Program
{
static void Main()
{
string rokuIp = "192.168.0.6";
string channelId = "dev";
string videoUrl = "http://video.ted.com/talks/podcast/DavidBrooks_2011.mp4";
// Note that the query string parameters should be url-encoded
string requestUrl = $"http://{rokuIp}:8060/launch/{channelId}?url={HttpUtility.UrlEncode(videoUrl)}";
using (var wc = new WebClient())
{
// POST the query string with no data
wc.UploadString(requestUrl, "");
}
}
}
下面的命令后在终端的作品的使用,实际上,这就是我想做的事,但在Java: 卷曲-d “”“http://10.50.0.46:8060/launch/12?url=http%3A%2F%2Fvideo.ted.com%2Ftalks%2Fpodcast%2FDavidBrooks_2011.mp4”
定义*不工作* – njzk2
该应用程序启动,但视频不被发送到应用程序,没有错误显示出来的代码,我发送视频到应用程序在电视机上。 (我正在使用connectionsdk作为Android应用程序) – UnknownDistance
您正在以get参数的形式写入视频网址。没关系,如果服务器想这样。 – greenapps