php curl堵塞问题,请帮忙,谢谢 40C

用户A,请求服务器B,服务器B需请求服务器C并等待C返回结果后,再将数据返回给A。

B访问C的延迟一般在0.8-2.5秒之间。 我采用的curl的方式。

在这种情况下,当用户请求频率在1秒5-6个的时候,就会出现访问超时,无法获得服务器B返回的数据。

这种情况如何处理。请赐教。

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
php curl传输文件问题,请路过的大神解答

最近项目开发碰上个问题,需要用到curl去掉第三方提供的接口,于是遍封装了一个公用方法: ``` public function request_post($url, $post_data = array(), $ispost = true) { if (empty($url) || empty($post_data)) { return false; } // return $url; $o = ""; foreach ( $post_data as $k => $v ) { $o.= "$k=" . urlencode( $v ). "&" ; } if($ispost){ $url=$url; // $post_data = http_build_query($post_data); }else{ $post_data = substr($o,0,-1); $url = $url.'?'.$post_data; } // header("Content-type: text/html; charset=utf-8"); $ch = curl_init();//初始化curl // curl_setopt($ch, CURLOPT_HTTPHEADER, array( // 'Content-Type: multipart/form-­data', // 'Content-Length: '.strlen($post_data) // )); curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页 // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, 0);//设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上 if($ispost){ curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } $data = curl_exec($ch);//运行curl curl_close($ch); return $data; } ``` 调用第三方接口时,一切正常,但是有一个地方需要用到上传二进制的音频文件,于是将界面获取到的音频文件转成blob格式提交PHP接口,PHP处理代码如下: ``` $speech = file_get_contents('php://input', 'r'); $param = array( speech => $speech ); return Request_curl::request_post($url, $param); ``` 本以为会放回成功的状态,但是现在是这样的: ``` { "msg": "语音数据错误,应为二进制类型", "code": 305 } ``` 请大神帮忙看下问题,感激不尽!

PHP并行cURL 502坏网关

<div class="post-text" itemprop="text"> <p>I'm using parallel cURL to download webpages source code by URL faster then single curl, but sometimes i get random amount of 502 error. If i'm using single cURL instead of parallel, i get less 502. Any solution how can i fix this?</p> <pre><code>502 Bad Gateway The server returned an invalid or incomplete response </code></pre> <p><strong>Tested with:</strong></p> <ol> <li><p>Localhost - XAMPP - PHP Version 7.0.13</p></li> <li><p>VPS - (LAMP) - PHP Version 7.0.25</p></li> </ol> <p><strong>PHP</strong></p> <pre><code> $curl_arr = array(); $master = curl_multi_init(); for($i = 0; $i &lt; count($urls); $i++) { $random = rand(1,9999); $link = trim($urls[$i]); $link = $link."?".$random; $url = trim($link); $curl_arr[$i] = curl_init($url); curl_setopt($curl_arr[$i], CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_arr[$i], CURLOPT_FRESH_CONNECT, TRUE); curl_setopt($curl_arr[$i], CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'); curl_setopt($curl_arr[$i], CURLOPT_HTTPHEADER, $headers); curl_setopt($curl_arr[$i], CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_arr[$i], CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl_arr[$i], CURLOPT_ENCODING , "gzip"); curl_setopt($curl_arr[$i], CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); curl_multi_add_handle($master, $curl_arr[$i]); } do { curl_multi_exec($master,$running); } while($running &gt; 0); </code></pre> </div>

我的PHP curl请求有什么问题,请帮忙..我没有收到任何数据[关闭]

<div class="post-text" itemprop="text"> <p>It says the browser sent a request the server could not understand .. I don't exactly understand what went wrong in my PHP code. Can someone please help me understand where I went wrong. Thanks !</p> <pre><code>&lt;?php $url ="http://127.0.0.1/sensor/sens/data.php"; $xml_data = file_get_contents("/usr/local/www/data/data.xml"); $header ="POST HTTP/1.0 "; $header .="Content-type: text/xml "; $header .="Content-length: ".strlen($xml_data)." "; $header .="Content-transfer-encoding: text "; $header .="Connection: close "; $header .= $xml_data; $ch = curl_init(); curl_setopt ($ch,CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$header); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); $data = curl_exec($ch); // if the post is successful , the server will return some data. echo $data; #$info = curl_getinfo($ch); # #if(!curl_errno($ch)) # echo 'It took '.$info['total_time'].'seconds to send a request to'.$info['url']; # # else # curl_close($ch); echo $data; ?&gt; </code></pre> </div>

Windows MAMP - PHP CURL问题

<div class="post-text" itemprop="text"> <p>I'm having issues with Windows MAMP Pro 3.3.1 getting PHP's CURL to work.</p> <p>More specifically issue is that I can send requests to APIs using curl_exec, but it always returns false.</p> <p>When I tried to do the same thing with XAMPP it returns full response with no issues.</p> <p>I tried changing PHP version, I checked that php curl extensions is enabled and I can see CURL info in phpinfo.</p> <p>Does any one know why and how to fix this issue with MAMP?</p> </div>

使用PHP Curl与命令行curl的区别

<div class="post-text" itemprop="text"> <p>I am integrating the Badgeville REST API with my PHP 5.3, curl 7.22 application.</p> <p>The API documentation for BV all uses command line curl calls for their examples. When I run these examples they work fine.</p> <p>When I attempt to do the same thing with the PHP Curl class I always get a 500 error from the BV server.</p> <p>I have tried to do the synonomous functionality with the Advanced Rest Client extension in Chrome.</p> <p>PHP Curl Example:</p> <pre><code>$ch = curl_init('http://sandbox.v2.badgeville.com/api/berlin/[private_api_key]/users.json'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); if($this-&gt;getRequestType() == 'POST') { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'user[name]' =&gt; 'Generic+Username', 'user[email]' =&gt; 'johndoe%40domainname.com' ); ); } $response = curl_exec($ch); </code></pre> <p>Rest Client Example:</p> <blockquote> <p>URL: http://sandbox.v2.badgeville.com/api/berlin/[private_api_key]/users.json</p> <p>POST No Headers Payload:</p> <p>user[name]=Generic+Username&amp;user[email]=johndoe%40domainname.com</p> </blockquote> <p>I have manually created the command line curl call and ran that with <code>shell_exec()</code>, but I would REALLY prefer not having to do that.</p> <p>In my research I found a Drupal <a href="http://drupalcode.org/project/badgeville_gamification.git/blob/2f5c27ba3f05651b55d0e8f54d117f441033bc66:/includes/badgeville.php" rel="nofollow">module</a> and all the API calls are done through <code>fsockopen()</code> calls.</p> <p>Is there some way to do successfully make Badgeville calls using the PHP Curl class?</p> </div>

PHP cURL错误500

<div class="post-text" itemprop="text"> <p>I have been trying to get data from this <a href="http://www.mytransport.sg/content/mytransport/home/myconcierge/trafficcameras.html" rel="nofollow">web page</a>. I found that I need to pass the camera id <a href="http://www.mytransport.sg/content/mytransport/home/myconcierge/trafficcameras/jcr%3acontent/par/cameras_slideshow.singleresult.html" rel="nofollow">to this url</a> using GET method to get image.</p> <p>But every time I do a curl request I got http_code 500: internal server error</p> <p>This is my code (I'm still trying out with static camera id):</p> <pre><code>$curl = curl_init('http://www.mytransport.sg/content/mytransport/home/myconcierge/trafficcameras/jcr:content/par/cameras_slideshow.singleresult.html?cameraid=4701'); curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.28 Safari/537.36"); curl_setopt($curl, CURLOPT_REFERER, "http://www.mytransport.sg/content/mytransport/home/myconcierge/trafficcameras.html"); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true); $resp = curl_exec($curl); echo $resp; $header = curl_getinfo($curl); echo "&lt;pre&gt;"; print_r($header); echo "&lt;/pre&gt;"; curl_close($curl); </code></pre> <p>Result I get:</p> <pre><code>HTTP/1.1 500 Internal Server Error Date: Mon, 09 Sep 2013 15:26:56 GMT Server: Microsoft-IIS/5.0 Last-Modified: Thu, 04 Oct 2012 15:55:23 GMT ETag: "7d2c5-402e-4cb3dc86ef0c0" Accept-Ranges: bytes Content-Length: 16430 Vary: Accept-Encoding Cache-Control: must-revalidate, proxy-revalidate, private, must-revaildate, proxy-revalidate, private Connection: close Content-Type: text/html </code></pre> </div>

php curl 提交参数中文乱码问题

A站通过url形式POST数据注册B站,psot的中文,在B站是显示乱码的; 直接贴码: $name="黄飞鸿"; $password="123456"; $get_url = "http://www.xxx.com/reg.php?name=".$name."&password=".$password $row=getToken($get_url); $obj=json_decode($row); function getToken($url){ $ch = curl_init(); $this_header = array("content-type: application/x-www-form-urlencoded; charset=UTF-8"); curl_setopt($ch, CURLOPT_HTTPHEADER,$this_header); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); return curl_exec($ch); } 对方收到的name是乱码的;导致注册失败。 求大侠支招~

PHP CURL DELETE请求

<div class="post-text" itemprop="text"> <p>I'm trying to do a DELETE http request using PHP and cURL.</p> <p>I have read how to do it many places, but nothing seems to work for me.</p> <p>This is how I do it:</p> <pre><code>public function curl_req($path,$json,$req) { $ch = curl_init($this-&gt;__url.$path); $data = json_encode($json); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $req); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data))); $result = curl_exec($ch); $result = json_decode($result); return $result; } </code></pre> <p>I then go ahead and use my function:</p> <pre><code>public function deleteUser($extid) { $path = "/rest/user/".$extid."/;token=".$this-&gt;__token; $result = $this-&gt;curl_req($path,"","DELETE"); return $result; } </code></pre> <p>This gives me HTTP internal server ERROR. In my other functions using the same curl_req method with GET and POST, everything goes well. </p> <p>So what am I doing wrong?</p> </div>

PHP cURL多处理性能比普通cURL慢

<div class="post-text" itemprop="text"> <p>I am trying to use cURL curl_multi_init() as a means to speed up requests. What I am experiencing though is that the request with the multi handles initinally take longer than the same request made with curl_init().</p> <p>Below is an example of two identical requests. <strong>Consistently</strong> the multi request takes about 4/5 times longer than the single request. The cURL options in both requests are identical. In this example the multi cURL only makes one request.</p> <p>Additional info: PHP 5.3.3/cURL 7.21.0, Windows server 2008/IIS 7x.</p> <p>I am totally flabbergasted about what could be causing this slow response. The request is being made to a server which resides in the same network, years of usage of the normal cURL has given me the experience that this kind of request, to this particular backend with non multi handling, take on average between 0.2/0.3 seconds.</p> <p>The question is: what could be causing this slowness of the multi cURL request.</p> <p>Below are the results of a test, two requests, one being done with curl_init(), the other with curl_multi_init (both in the same script). Notice the cURL info, the requests being exactly the same in terms of header_size, request_size, size_upload, size_download and download_content_length.</p> <p>Test with normal cURL:</p> <pre><code>Array ( [url] =&gt; http://myurl.com [content_type] =&gt; text/xml;charset=UTF-8 [http_code] =&gt; 200 [header_size] =&gt; 261 [request_size] =&gt; 312 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 0 [total_time] =&gt; 0.203 [namelookup_time] =&gt; 0 [connect_time] =&gt; 0.015 [pretransfer_time] =&gt; 0.015 [size_upload] =&gt; 174 [size_download] =&gt; 236 [speed_download] =&gt; 1162 [speed_upload] =&gt; 857 [download_content_length] =&gt; 236 [upload_content_length] =&gt; 0 [starttransfer_time] =&gt; 0.203 [redirect_time] =&gt; 0 ) </code></pre> <p>Test with multi cURL (notice the speed upload/download is lower, connect and name lookup time higher):</p> <pre><code>Array ( [client] =&gt; Array ( [url] =&gt; http://myurl.com [content_type] =&gt; text/xml;charset=UTF-8 [http_code] =&gt; 200 [header_size] =&gt; 261 [request_size] =&gt; 312 [filetime] =&gt; -1 [ssl_verify_result] =&gt; 0 [redirect_count] =&gt; 0 [total_time] =&gt; 1.047 [namelookup_time] =&gt; 0.61 [connect_time] =&gt; 0.61 [pretransfer_time] =&gt; 0.61 [size_upload] =&gt; 174 [size_download] =&gt; 236 [speed_download] =&gt; 225 [speed_upload] =&gt; 166 [download_content_length] =&gt; 236 [upload_content_length] =&gt; 0 [starttransfer_time] =&gt; 1.047 [redirect_time] =&gt; 0 [multi_handle_info] =&gt; Array ( [msg] =&gt; 1 [result] =&gt; 0 [handle] =&gt; Resource id #5 ) ) ) </code></pre> <p>Example of the code for the multi cURL (options are same as in the code for normal cURL):</p> <pre><code>$curl = array(); $result = array(); $mh = curl_multi_init(); foreach (array_keys($queries) as $id) { $curl[$id] = curl_init(); curl_setopt($curl[$id], CURLOPT_URL,$queries[$id]['url']); curl_setopt($curl[$id], CURLOPT_RETURNTRANSFER,1); curl_setopt($curl[$id], CURLOPT_CONNECTTIMEOUT,60); curl_setopt($curl[$id], CURLOPT_DNS_CACHE_TIMEOUT,3600); curl_setopt($curl[$id], CURLOPT_TIMEOUT, 240); curl_setopt($curl[$id], CURLOPT_POSTFIELDS, $queries[$id]['post']); curl_multi_add_handle($mh, $curl[$id]); } $running = null; do { curl_multi_exec($mh, $running); } while($running &gt; 0); // get content and remove handles foreach($curl as $id =&gt; $c) { $result[$id] = curl_multi_getcontent($c); curl_multi_remove_handle($mh, $c); } </code></pre> </div>

为什么centos curl版本与php curl版本不同

<div class="post-text" itemprop="text"> <p>I updated centos7 curl and now the version is 7.65, then I rebuilt php7 and <code>set --with-curl=/usr/bin/curl</code>. When I finished <code>curl_version()</code> still shows 7.20. Why is that?</p> <p>I use guzzle to request a web which need http_version 2.0, so I have to upgrade php curl. Hope someone helps me, thanks a lot!</p> </div>

PHP cURL遵循重定向并获得结果

<div class="post-text" itemprop="text"> <p>If you visit URL:</p> <p><a href="https://selfsolve.apple.com/agreementWarrantyDynamic.do?caller=sp&amp;sn=990002316140324" rel="nofollow">https://selfsolve.apple.com/agreementWarrantyDynamic.do?caller=sp&amp;sn=990002316140324</a></p> <p>then it will redirect and results will be shown at URL:</p> <p><a href="https://selfsolve.apple.com/wcResults.do" rel="nofollow">https://selfsolve.apple.com/wcResults.do</a></p> <p>I'm trying with PHP cURL to get this results but the page is empty. Its not redirecting.</p> <p>Here is my code which I tried: </p> <pre><code>&lt;?php $url ='https://selfsolve.apple.com/agreementWarrantyDynamic.do?caller=sp&amp;sn=990002316140324'; $http_headers = array( 'Accept: /*', 'Connection: keep-alive' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $http_headers); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'); curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/applecookie.txt'); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); $retValue = curl_exec($ch); $response = json_decode(curl_exec($ch)); $ee = curl_getinfo($ch); print_r($ee); print_r($retValue); ?&gt; </code></pre> <p>How to make it work?</p> </div>

php curl重置或修改cookie

<div class="post-text" itemprop="text"> <p>PHP-CURL: How the hell can I modify or delete cookies after calling curl_exec in existing curl object?</p> <p>1) "Cookiejar" file is not saved on disk until curl_close()!</p> <p>2) CURLOPT_COOKIE - can't help, just adding cookie with same name, not removing/editing older one.</p> <p>3) CURLOPT_HTTPHEADER - setting "Cookie: " - can't help too! </p> <p>I just need to edit or totally remove that cookies without closing - re-creating curl object =(</p> </div>

PHP cURL没有发送POST数据

<div class="post-text" itemprop="text"> <p>I am trying to send some data from my php to a rest service. It seems to make a call correctly to the API but doesnt send any post data.</p> <p>The Code is :</p> <pre><code>&lt;?php $name="abcd"; $id="xyz"; $service_url = 'service/url'; $curl = curl_init($service_url); $curl_post_data = array( $name,$id); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); $curl_response = curl_exec($curl); curl_close($curl); ?&gt; </code></pre> <p>I would also like to manipulate the response provided.Can someone tell what i am doing wrong here.</p> <p>There is a server side validation, The code is :</p> <pre><code>private String validateAndGetClientName(HttpServletRequest request) throws InvalidRequestException { String clientName = request.getParameter("name"); if (isEmpty(clientName)) { throw new InvalidRequestException("Client Name cannot be empty."); } return clientName.trim(); } </code></pre> </div>

将语法从cURL转换为php cURL

<div class="post-text" itemprop="text"> <p>I have a cURL command which works very well en CLI (via git Bash). See below:</p> <pre><code>curl -D- -k -o tvdata.xls -u adminid:adminpw -X GET -H "Content-Type: application/vnd.ms-excel" https://localhost/jira/sr/jira.issueviews:searchrequest-excel-current-fields/temp/SearchRequest.xls?jqlQuery=project+%3D+LPCCU+AND+type+%3D+Incident </code></pre> <p>This command export very well all issues in an excel file (xls) from my JIRA. Now i want to transform this command to php curl. I have tried this code below:</p> <pre><code> $url = 'https://build.bnum.laposte.fr/jira/sr/jira.issueviews:searchrequest-excel-current-fields/temp/SearchRequest.xls?jqlQuery=project+%3D+LPCCU+AND+type+%3D+Incident'; $username ='adminid'; $password ='adminpw'; $file = fopen('tvdata.xls', 'w'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/vnd.ms-excel")); curl_setopt($ch, CURLOPT_NOPROGRESS, FALSE); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 15000); curl_setopt($ch, CURLOPT_FILE, $file); curl_exec($ch); curl_close($ch); fclose($file); </code></pre> <p>but when i run this php code, he create an <strong>empty</strong> excel file only, but without to get an error. If somebody can figure out this problem please?</p> <p>Thanks in advance</p> <p>Achillix</p> </div>

Php curl post数据参数有时会发送为空

<div class="post-text" itemprop="text"> <p>I am trying to call service with three parameters: uri, code and type. But sometimes "type" parameter posting empty, sometimes posting correct. So service call sometimes successfull, sometimes fail. I don't change anything but parameter "type" sometimes empty. How can ı solve this problem ?</p> <pre><code>$curl_post_data = array( "uri" =&gt; $uri, "code" =&gt; $code, "type" =&gt; $type ); $post_data = http_build_query($curl_post_data); $curl = curl_init($service_url); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($curl, CURLOPT_TIMEOUT, 10); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_HTTPAUTH, xxx); curl_setopt($curl, CURLOPT_USERPWD, xxx); curl_setopt($curl, CURLOPT_PROXY, 'xxx'); curl_setopt($curl, CURLOPT_PROXYUSERPWD, 'xxxx'); curl_setopt($curl, CURLOPT_PROXYPORT, xxx); curl_setopt($curl, CURLOPT_PROXYAUTH, xxx); $curl_response = curl_exec($curl); if (false === $curl_response) { return null; } </code></pre> </div>

php的cURL问题

<div class="post-text" itemprop="text"> <p>When i am tryin to manualy fetch a php page by passing URL, an exception is appearing which says </p> <p>javax.servlet.ServletException: java.lang.RuntimeException: PHP Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.</p> <p>but when I searched php curl in my insatllation directory, I found it there.</p> <pre><code>[ashish@hpproliant ~]$ which php /usr/local/bin/php [ashish@hpproliant ~]$ which curl /usr/local/bin/curl </code></pre> <p>I have modified php.ini file where a line related to curl was commented..What do i need do do now?? Thanks</p> </div>

PHP curl返回空白页面

<div class="post-text" itemprop="text"> <p>Can anyone show me how to compose this request using curl php? I need to scrape a website, but the code I use (given below) always returns a blank page. I want to send </p> <pre><code>Accept-Encoding, Useragent, and cookie </code></pre> <p>Request:</p> <pre><code>Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1 Accept-Encoding: gzip </code></pre> <p>to </p> <p><a href="https://example.com/" rel="nofollow">https://example.com/</a></p> <p>Thanks!</p> <p>The code I tried to use (returned a blank page):</p> <pre><code>&lt;? $url='https://example.com'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); $request_headers = array(); $request_headers[] = 'Accept-Encoding: gzip'; $request_headers[] = 'Client: Apple'; curl_setopt($ch, CURLOPT_COOKIE, 'insertedmycookiehere'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $curl_scraped_page = curl_exec($ch); curl_close($ch); echo $curl_scraped_page; ?&gt; </code></pre> <p>Did I do something wrong?</p> </div>

php cURL 上传文件失败

curlPost.php ``` <?php $post = array( 'name' => 'wyjie', 'img' => '@D:/debug.exe' ); //cURL发送post请求 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/demo/demo/curl/01.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $optput = curl_exec($ch); curl_close($ch); echo $optput; ?> ``` 01.php ``` <?php print_r($_POST); print_r($_FILES); ?> ``` 输出结果 Array ( [name] => wyjie [img] => @./debug.exe ) Array ( )

PHP无法加载php_curl.dll扩展

<div class="post-text" itemprop="text"> <p>Follow-up from my post yesterday (<a href="https://stackoverflow.com/questions/16403376/enabling-curl-with-php">Enabling cURL with PHP</a>)</p> <p>The problem is that PHP isn't able to load php_curl.dll. I've tried several steps including uncommenting <code>extension=php_curl.dll</code>, making sure the dependencies <code>libeay32.dll</code> and <code>ssleay32.dll</code> eixst in the path, re-downloading php_curl.dll, replacing the old one, and lastly copying the file into my System32 folder.</p> <p>I'm using Apache 2.2 and PHP 5.4.14. I installed both using their individual packages; I'm not using XAMP or WAMP. I'm using Windows 7 64-bit.</p> <p>Any help at all would be appreciated.</p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

点沙成金:英特尔芯片制造全过程揭密

“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

C++11:一些微小的变化(新的数据类型、template表达式内的空格、nullptr、std::nullptr_t)

本文介绍一些C++的两个新特性,它们虽然微小,但对你的编程十分重要 一、Template表达式内的空格 C++11标准之前建议在“在两个template表达式的闭符之间放一个空格”的要求已经过时了 例如: vector&lt;list&lt;int&gt; &gt;; //C++11之前 vector&lt;list&lt;int&gt;&gt;; //C++11 二、nullptr ...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

【阿里P6面经】二本,curd两年,疯狂复习,拿下阿里offer

二本的读者,在老东家不断学习,最后逆袭

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

微软为一人收购一公司?破解索尼程序、写黑客小说,看他彪悍的程序人生!...

作者 | 伍杏玲出品 | CSDN(ID:CSDNnews)格子衬衫、常掉发、双肩包、修电脑、加班多……这些似乎成了大众给程序员的固定标签。近几年流行的“跨界风”开始刷新人们对程序员的...

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

我说我懂多线程,面试官立马给我发了offer

不小心拿了几个offer,有点烦

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

立即提问
相关内容推荐