Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php \'类型的CURL对象;System.DBNull\';无法转换为\';系统字符串_Php_Asp.net_Curl_Cross Domain - Fatal编程技术网

Php \'类型的CURL对象;System.DBNull\';无法转换为\';系统字符串

Php \'类型的CURL对象;System.DBNull\';无法转换为\';系统字符串,php,asp.net,curl,cross-domain,Php,Asp.net,Curl,Cross Domain,我试图从网站/服务器收到一些响应,我得到的回报是: System.ArgumentException','Object of type \'System.DBNull\' cannot be converted to type \'System.String 我的PHP代码: $url = 'website'; $fields = array('searchstring' => urlencode('solkrem'), 'menuID' => urlencode(0), 'gen

我试图从网站/服务器收到一些响应,我得到的回报是:

System.ArgumentException','Object of type \'System.DBNull\' cannot be converted to type \'System.String
我的PHP代码:

$url = 'website';
$fields = array('searchstring' => urlencode('solkrem'), 'menuID' => urlencode(0), 'genses' => urlencode('20170201178577A2F54'), 'removeimages' => urlencode(false));

function httpPost($url, $data)
{
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}

echo "<br><br>";

$result = httpPost($url,$fields);

var_dump($result);
收到的请求标头:

HTTP/1.1 200 OK
Date: Thu, 02 Feb 2017 14:03:20 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private
Expires: Thu, 02 Feb 2017 14:03:19 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 58300
编辑3:

我发现,即使该站点要求我使用&separator添加详细信息,如果是这样,它也不会工作,并且会产生相同的错误:

但是如果它看起来像这样,没有&分隔符,它就可以工作。我不知道它是如何发送的,因为它的后端PHP在测试页面上

此外,如果我不发送任何字段,它将给出与我的错误相同的输出

更新4:

从他们的网站上,我看到他们发送信息的方式如下:

'searchstring=solkrem\r\nmenuID=0\r\ngenses=20170201178577A2F54\r\nremoveimages=false

那会有什么作用吗?嗯。

我想你的错误是“removeimages”参数

你有:

'removeimages' => urlencode(false)
这可能是:

'removeimages' => urlencode('false')

将布尔值编码为false的URL不会在查询字符串中传递任何内容,也不会在另一端创建空值

该错误由另一个系统生成。它表示您在一个变量中传递一个null(nothing),该变量需要一个字符串。请查看您联系的系统的文档,并相应地更改您的帖子。谢谢@Andy,但我不知道他们使用的是什么系统。更新的主题@Andy您不需要将
&
放在字段之间。http\u build\u查询将为you@AndyC如果我不想要&,怎么办?我可以删除构建并构建自己的构建吗?或者?恐怕这没什么区别。@maria尝试添加
curl\u setopt($curl,CURLOPT\u HTTPHEADER,array('Content-Type:application/x-www-form-urlencoded')恐怕没有区别:|我认为您不需要对数据进行URL编码,因为http|U build|U查询将为您实现这一点。如果您想尝试用
'\r'
分隔字段,可以将
http\u build\u query($data)
更改为
http\u build\u query($data,,'\r')
,这样它将删除&并替换为\r?
'removeimages' => urlencode('false')