Curl无法在IIS 7.5 windows server 2008 r2中从php调用ashx

我正在尝试使用curl从php文件中调用ashx文件,例如index.php。 使用的网址是</ p>

  http://example.com/forms/YYY.ashx
$ch = curl_init();
curl_setopt($ ch,CURLOPT_URL,$ url );
; ncurl_setopt($ ch,CURLOPT_VERBOSE,false);
curl_setopt($ ch,CURLOPT_HEADER,false);
curl_setopt($ ch,CURLOPT_POST,true);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ ch,CURLOPT_POSTFIELDS,$ data);
$ ret = curl_exec($ ch);
echo curl_getinfo($ ch,CURLINFO_HTTP_CODE);

if($ ret === false){
echo curl_error($ ch) ;
// die(curl_error($ ch));
}

ncurl_close($ ch);
return $ ret;
</ code> </ pre>

当我 运行这个,我得到$ ret为false,curl_error为null [empty]和 curl_getinfo($ ch,CURLINFO_HTTP_CODE)为0 </ code>。 它只是我没想到网址</ p>

你能帮我解决一下这个问题</ p>

其他信息:</ p> \ n


  1. 将IIS 7.5与Windows Server 2008 r2一起用作操作系统</ li>
  2. 安装php 5.3.28版本,并在php.ini文件中启用curl。</ li> \ n
  3. Extension_dir设置为路径C:\ Program Files(x86)\ PHP \ v5.3 \ ext

    </ li>

  4. 已安装PHP管理器 所有的设置和扩展都是
    显示正确</ li>
    </ ol>
  5. 即使在所有这些之后我也无法通过php访问该ashx文件。 如果我错过任何配置,请告诉我?</ p>
    </ div>

展开原文

原文

I am trying to invoke ashx file from php file say index.php using curl. The url used is

http://example.com/forms/YYY.ashx
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$ret = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($ret === false) {
    echo curl_error($ch);
  //die(curl_error($ch));
}

curl_close($ch);
return $ret;

When i run this, i get $ret as false, curl_error as null [empty] and curl_getinfo($ch, CURLINFO_HTTP_CODE) as 0. Its not hitting the URL only i guess

Can you guys please help me to identify the issue with this

Other Info:

  1. Using IIS 7.5 with windows server 2008 r2 as OS
  2. Installed php 5.3.28 version with curl enabled in php.ini file.
  3. Extension_dir is set to path C:\Program Files (x86)\PHP\v5.3\ext in php.ini, where php is installed.
  4. PHP manager is installed and all the setting and extensions are showing as correct

Even after all these i am not able to hit that ashx file via php. Please let me know if i missed any configuration?

douyanyan1123
douyanyan1123 嗨PravinS,我尝试给print_r(curl_getinfo($ch))并输出为[url]=>example.com/forms/YYY.ashx[content_type]=>[http_code]=>0[header_size]=>0[request_size]=>0[filetime]=>-1[ssl_verify_result]=>0[redirect_count]=>0[total_time]=>0.031[namelookup_time]=>0.016[connect_time]=>0.031[pretransfer_time]=>0[size_upload]=>0[size_download]=>0[speed_download]=>0[speed_upload]=>0[download_content_length]=>-1[upload_content_length]=>-1[starttransfer_time]=>0[redirect_time]=>0[certinfo]=>Array()[redirect_url]=>
6 年多之前 回复
dongyun6835
dongyun6835 使用print_r()检查curl_getinfo()值,因为curl_getinfo()返回关联数组
6 年多之前 回复
dr5779
dr5779 注意:Asp,ashx和php文件位于IIS7.5中托管的同一网站中,并尝试将应用程序池更改为集成模式和经典模式
6 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐