fsockopen

Preventing warnings from fsockopen

南笙酒味 提交于 2019-12-19 16:54:40
问题 I use fsockopen() to connect to multiple servers in a loop. However some servers are not valid and I get PHP warnings like the one below: Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found Is there a way to prevent these warnings. Like checking whether the server is good before trying to fsockopen it? Or is there another or better solution for this? 回答1: Use the error control

Preventing warnings from fsockopen

≯℡__Kan透↙ 提交于 2019-12-19 16:54:07
问题 I use fsockopen() to connect to multiple servers in a loop. However some servers are not valid and I get PHP warnings like the one below: Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found Is there a way to prevent these warnings. Like checking whether the server is good before trying to fsockopen it? Or is there another or better solution for this? 回答1: Use the error control

php中socket、fsockopen、curl、stream 区别

不想你离开。 提交于 2019-12-19 09:51:54
socket 水泥、沙子,底层的东西 fsockopen 水泥预制件,可以用来搭房子 curl 毛坯房,自己装修一下就能住了 水泥、沙子不但可以修房子,还能修路、修桥、大型雕塑。socket也是,不但可以用于网页传输,还能传送其他东西,可以做聊天工具、下载器、ftp……几乎可以用网络传送的东西都能用它写出来,当然,需要掌握的知识也不少,例如建墙你就要知道怎么让墙笔直、不易倒、防冻、隔热等等都需要自己学 预制件你就不用管它是否笔直、结构如何、怎样隔热了,这些造的人帮你想好了,你想的就是怎样搭成你想要的形状就行。fsockopen就是,你可以忽略socket里面的creat, connect, send, recv等等函数的用法,直接就open了 毛坯房就更简单了,你装修就能住,最简单刷墙就行了,但想更舒适,就用更多更好的装修材料吧,但缺点就是——这是房子,你不能把它改造为渡河、交通的用途,只能住 curl也一样,各种连接什么的都帮你做好了,底层容错处理也做了,你就传参数给它就能得到你想要的结果,但缺点就是只能http / ftp,你想把它改成聊天工具,那就难难难了 stream_socket_client 和 fsockopen 没有本质上的区别 socket 是一个封装了 TCP/IP 操作的工具包 stream_socket_client 和 fsockopen 分属不同流派的对

How do I get SSL working in fsockopen?

好久不见. 提交于 2019-12-18 14:11:39
问题 I'm running PHP 5.2.6 on Windows, I have extension=php_curl.dll and extension=php_openssl.dll uncommented in php.ini; as such I can see the following in phpinfo : curl cURL support enabled cURL Information libcurl/7.16.0 OpenSSL/0.9.8g zlib/1.2.3 openssl OpenSSL support enabled OpenSSL Version OpenSSL 0.9.8g 19 Oct 2007 I'm not sure that having cURL enabled is vital to this, but since it mentioned OpenSSL I thought I'd include it here anyway for completeness. What I want to do is simple: make

php_network_getaddresses: getaddrinfo failed: Name or service not known

故事扮演 提交于 2019-12-17 10:34:17
问题 Here is a snippet of my code $fp = fsockopen($s['url'], 80, $errno, $errstr, 5); if($fp){ fwrite($fp, $out); fclose($fp); When I run it, it outputs: unable to connect to www.mydomain.net/1/file.php:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known I'm using this to submit GET data to the $s['url'] I can't figure out why. Any help would be greatly appreciated. 回答1: If you only want to submit GET data to the URL, you should use something straightforward like file_get

How to check if a file exists from a url

末鹿安然 提交于 2019-12-17 04:54:14
问题 I need to check if a particular file exists on a remote server. Using is_file() and file_exists() doesn't work. Any ideas how to do this quickly and easily? 回答1: You have to use CURL function does_url_exists($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($code == 200) { $status = true; } else { $status = false; } curl_close($ch); return $status; } 回答2: You don't need CURL for that... Too much overhead

Socket transport “ssl” in PHP not enabled

流过昼夜 提交于 2019-12-17 04:22:04
问题 I'm having trouble enabling the socket transport "ssl" in PHP. When I run my script, I get the error: Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://www.my.site.com:443 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) I'm running IIS6 on Windows and this is what I've done so far to try to get it working: uncommented the php_openssl.dll and php_sockets.dll extensions in php.ini made sure PHP was loading the ini file I

fsockopen ssl connection not working

你离开我真会死。 提交于 2019-12-14 03:54:40
问题 I'm trying to use php function fsockopen on a smtp server using ssl on port 465 on my local server with apache. It works well with php command line but I get a SSL error when the script is running in my browser. php.ini extension=php_openssl.dll line is not commented phpinfo through Apache Loaded Configuration File : D:\localhost\php-5.4.11\php.ini openssl OpenSSL support enabled OpenSSL Library Version OpenSSL 0.9.8x 10 May 2012 OpenSSL Header Version OpenSSL 0.9.8x 10 May 2012 phpinfo with

Overlapping HTTPS requests?

故事扮演 提交于 2019-12-13 10:28:58
问题 Is there an example where I am able to do overlapping HTTPS requests while getting the returned results as they arrive. Language which supports threads to do this? Any examples of this would be much appreciated! Thank you. 回答1: curl multi-request functionality may be useful in this case. The example is with regular http but should work with https too. If you need to process data as they come, use curl's write handler functions set by CURLOPT_WRITEFUNCTION option. 来源: https://stackoverflow.com

快速解决在TP5中无法使用快递鸟的即时查询API

孤人 提交于 2019-12-13 05:22:38
快递鸟的接口对接其实很简单,先去官网注册账号,登陆把基本信息填好,然后在产品管理中订购一下“物流查询”,免费,不过其他产品是收费,免费的有对接口调用频率限制,结合自己的应用流量够用就可以。 使用前复制一下账号下的用户ID和API key,并且快递鸟对各个API提供了各种语言的demo,其实下载下来,找一下平时寄快递的运单号,本地运行一下就能用了。(名称: KdApiSearchDemo) 其实拿到demo代码,可以放到项目中,因为demo是以面向过程写的,所以为了方便自然就想封装一下。 <?php namespace data\extend; use data\service\Config; /** * 快递鸟即时查询接口 * @author Administrator * */ class Kdniao{ private $ebusinessid;//商户ID private $appkey; //商户秘钥 private $request_type;//请求类型 private $request_url; //请求URL /** * 构造函数 */ public function __construct($shop_id){ $config=new Config(); $express_config=$config->getOrderExpressMessageConfig(