curl-multi

PHP curl_multi_getcontent returns null

偶尔善良 提交于 2019-12-18 15:16:38
问题 I have been following this tutorial on how to use curl_multi . http://arguments.callee.info/2010/02/21/multiple-curl-requests-with-php/ I can't tell what I am doing wrong, but curl_multi_getcontent is returning null. It is suppose to return JSON. I know it is not the mysql call as I had it working with a while loop and standard curl_exec , but The page was taking too long to load. (I've changed some of the setopt details for security) Relevant PHP Code snippet. I do close the while loop in

How to fix curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s)

我的未来我决定 提交于 2019-12-18 10:34:43
问题 I am trying to access and download some .torrent files from https://torrage.com using php curl . But nothing happens , curl_error($ch) gives $ch = curl_init ('https://torrage.com/torrent/640FE84C613C17F663551D218689A64E8AEBEABE.torrent'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT

Asynchronous HTTP requests in PHP

白昼怎懂夜的黑 提交于 2019-12-17 12:17:28
问题 Is there any sane way to make a HTTP request asynchronously in PHP without throwing out the response? I.e., something similar to AJAX - the PHP script initiates the request, does it's own thing and later, when the response is received, a callback function/method or another script handles the response. One approach has crossed my mind - spawning a new php process with another script for each request - the second script does the request, waits for the response and then parses the data and does

why curl_multi_exec in two loops

£可爱£侵袭症+ 提交于 2019-12-12 04:56:17
问题 I saw a piece of example code, i wonder why use two do-while loops? what are difference between the two loops? wait reply online, Thank You~~ do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active && $mrc == CURLM_OK) { if (curl_multi_select($mh) != -1) { do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } 回答1: As presented, the first loop is intended to initialize the HTTP clients. Normally it only executes

Get cUrl to preemptively send Authorization header for DIGEST authentication in PHP

。_饼干妹妹 提交于 2019-12-12 01:32:37
问题 We have a PHP page (actually a WordPress plugin) which makes calls to a REST API with DIGEST authentication. The curl handle is created on a per request basis, given authorisation credentials and successfully authenticates. PROBLEM: Under the hood, Curl is sending two requests. The first fails with a 401 and a challenge, the second contains an Authorization header and succeeds (200) Upon subsequent API calls cUrl continues to send two requests. This seems inefficient, causing 2 x network

Amazon AWS PHP SDK with Guzzle's MultiCurl?

佐手、 提交于 2019-12-12 01:14:54
问题 I need to perform some fairly heavy queries with Amazon's AWS SDK for PHP. The most efficient way would be to use PHP's MultiCurl. It seems that Guzzle already has functionality for MultiCurl built in. Does using the standard methods provided by the AWS SDK automatically use MultiCurl or do I have to specify it's usage directly? E.g. calling $sns->Publish() 30 times. Thanks! 回答1: Parallel requests work exactly the same in the SDK as in plain Guzzle and do take advantage of MultiCurl. For

“Could not resolve host” error with curl_multi on cURL version 7.64

时间秒杀一切 提交于 2019-12-11 03:31:02
问题 I'm getting "Could not resolve host" when I call curl_error($ch) in curl_multi context, the errno is 0 though, and the request is done successfully also(I'm getting the expected response from the remote server). I'm getting this error for all the requests in the curl_multi group, except for only the first request of them which is done without any error messages! (for example if the curl_multi has 10 sub requests attached to it, only the first request will not have the error and the other 9

How many times does curl_multi_exec have to be called?

♀尐吖头ヾ 提交于 2019-12-10 23:30:01
问题 I'm using curl_multi with multi to upload files to different servers. Each server has multiple files that need uploading, so I have a curl_multi request for each server. When I execute the curl_multi handles, I just execute all the curl_multi handles in the same loop, like so: <?php do { $continue_running=false; foreach($handles as $host => $handle) { if(!is_resource($handle[0])) { die("\nHandle is not a resource!\n"); } if($running_{$host}) { if(curl_multi_exec($handles[$host][0], $running_{

Simulating a cookie-enabled browser in PHP

余生长醉 提交于 2019-12-10 10:26:17
问题 How can I open a web-page and receive its cookies using PHP? The motivation : I am trying to use feed43 to create an RSS feed from the non-RSS-enabled HighLearn website (remote learning website). I found the web-page that contains the feed contents I need to parse, however, it requires to login first. Luckily, logging in can be done via a GET request so it's as easy as fopen()ing "http://highlearn.website/login_page.asp?userID=foo&password=bar" for example. But I still need to get the cookies

Get all the URLs using multi curl

江枫思渺然 提交于 2019-12-10 03:49:20
问题 I'm working on an app that gets all the URLs from an array of sites and displays it in array form or JSON. I can do it using for loop, the problem is the execution time when I tried 10 URLs it gives me an error saying exceeds maximum execution time . Upon searching I found this multi curl I also found this Fast PHP CURL Multiple Requests: Retrieve the content of multiple URLs using CURL. I tried to add my code but didn't work because I don't how to use the function. Hope you help me. Thanks.