dsv768456 2010-09-17 23:23
浏览 266
已采纳

为什么cURL报告无效的IP地址为错误?

I have the following PHP code that uses cURL:

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,"http://area51.stackexchange.com/users/flair/31.json");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

$a_data = json_decode(curl_exec($ch));

echo curl_error($ch);

I then get the following error when I try to access the page over HTTP:

Failed to connect to 0.0.0.31: Invalid argument

However, the code works fine when run from the command line.

What could possible cause cURL to try to connect to 0.0.0.31, which is AFAIK, not even a valid IP address?

  • 写回答

3条回答 默认 最新

  • douyin9987 2010-09-17 23:51
    关注

    "What could possible cause cURL to try to connect to 0.0.0.31, which is AFAIK, not even a valid IP address?"

    Your DNS is botched. I tested your code and it works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看