dpge74512 2013-04-23 14:28
浏览 199
已采纳

在PHP cURL请求中转换C#HttpWebRequest

I'm new with cURL, I succeeded with my first request but now I'm stuck. I have the right request in C# but I don't know how to convert the second in cURL PHP.

Here is the HttpWebRequest:

var request = (HttpWebRequest)WebRequest.Create(new Uri("https://www.google.fr"));
request.Method = HttpMethod.Get;
request.Headers["X-343-Authorization-WLID"] = "v1=" + accessToken;
request.Accept = "application/json";

accessToken is a string variable of course.

  • 写回答

1条回答 默认 最新

  • dsjbest2014 2013-04-23 14:38
    关注

    Here are the three base curl_setopt calls you'll need to make.

    curl_setopt($ch,CURLOPT_URL,"$website");
    curl_setopt($ch,CURLOPT_ENCODING, 'application/json');
    curl_setopt($ch,CURLOPT_HTTPHEADER, array("X-343-Authorization-WLID:v1=$accesstoken"));
    

    You might want to add follow_location and return_transfer, but I don't know exactly what you're doing. Both of those options are listed in the curl_setopt documentation.

    That page should have enough examples to get you going.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示