【发布时间】:2017-05-19 09:22:41
【问题描述】:
当我使用邮递员应用程序点击以下网址时,它工作正常
http://192.168.1.220/cgi-bin/handle_login.tcl
但是当尝试使用 curl 时,它给了我以下错误
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
下面是我的php代码
<?php
$postData = array(
'user' => 'admin',
'pw' => 'admin',
'submit' => 'Login'
);
// Setup cURL
$ch = curl_init('http://192.168.1.220/cgi-bin/handle_login.tcl');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
var_dump($response);
// Check for errors
if($response === FALSE){
die(curl_error($ch));
}
// Decode the response
$responseData = json_decode($response, TRUE);
// Print the date from the response
echo $responseData['published'];
?>
【问题讨论】:
-
您似乎严重误解了 Stack Overflow 的工作原理。请查看help center,主要是How to Ask和Be Nice。
-
@Nitish..u 认为我发布了支持投票的问题 ....在以前的问题之一中,用户心甘情愿地投票并发布了一些不相关的答案,并要求我进行绿色勾号和支持投票...我不这样做..我面临错误我发布了我得到的东西......如果你想帮助我,只需通知我我所做的错误......
-
大声笑...@Nitish ....我想你一直在通过我的帖子....我认为我自己发布了答案......
标签: php web-services curl