欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

大哥们再帮忙看看这个 java 2 php.

程序员文章站 2022-04-13 20:59:37
...
它们说的头部, 和用curl的header一个样吗?
  ...
  URL httpUrl = new URL(billing_url);
  HttpURLConnection http = (HttpURLConnection)httpUrl.openConnection();
  http.setRequestProperty("opcode", String.valueOf(opcode));    //头部
  http.setRequestProperty("appkey",appkey);             //头部
  http.setRequestProperty("sign", sign);            //头部
  http.setRequestProperty("tag", String.valueOf(tag));      //头部
  http.setRequestProperty("channelId",String.valueOf(channelId)); //头部
  http.setConnectTimeout(3000);
  http.setRequestMethod("POST"); //post方式
  http.setDoInput(true);
  http.setDoOutput(true);
  PrintWriter out = new PrintWriter(http.getOutputStream());
  out.print("data="+data); //注意data传递方式
  out.flush();
  ...

这个问题已被关闭,原因:

回复内容:

它们说的头部, 和用curl的header一个样吗?

  ...
  URL httpUrl = new URL(billing_url);
  HttpURLConnection http = (HttpURLConnection)httpUrl.openConnection();
  http.setRequestProperty("opcode", String.valueOf(opcode));    //头部
  http.setRequestProperty("appkey",appkey);             //头部
  http.setRequestProperty("sign", sign);            //头部
  http.setRequestProperty("tag", String.valueOf(tag));      //头部
  http.setRequestProperty("channelId",String.valueOf(channelId)); //头部
  http.setConnectTimeout(3000);
  http.setRequestMethod("POST"); //post方式
  http.setDoInput(true);
  http.setDoOutput(true);
  PrintWriter out = new PrintWriter(http.getOutputStream());
  out.print("data="+data); //注意data传递方式
  out.flush();
  ...
相关标签: php java