在php中使用c#rest web服务
我试图通过php连接到c#rest web服务,但当我执行以下代码时,发生了此错误: “消息”:“请求的资源不支持http方法‘GET’” 有人能帮我解决这个错误吗在php中使用c#rest web服务,php,rest,curl,Php,Rest,Curl,我试图通过php连接到c#rest web服务,但当我执行以下代码时,发生了此错误: “消息”:“请求的资源不支持http方法‘GET’” 有人能帮我解决这个错误吗 <?php $url="https://example/login"; $username='user'; $password='pass'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD,$u
<?php
$url="https://example/login";
$username='user';
$password='pass';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD,$username':'$password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$out = curl_exec($ch);
print "error:" . curl_error($ch) . "<br />";
echo $out;
curl_close($ch);
?>
默认情况下,
curl
通过HTTP GET执行请求。必须通过POST访问web服务
查看有关如何通过curl创建POST请求的详细信息。默认情况下,
curl
通过HTTP GET执行请求。必须通过POST访问web服务
请查看有关如何通过curl创建POST请求的详细信息