1

I'm using PHP's CURL MULTI to download an array of resources in parallel, and I want to get the last effective URL from each of the resources (not just the last one).

Basically, I'm looking for:

curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

for CURL MULTI, something like:

curl_multi_getinfo($ch[$key], CURLINFO_EFFECTIVE_URL);

Any ideas?

Lorien Brune
  • 830
  • 10
  • 16

2 Answers2

0

I haven't tried it, but curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); should work just fine with the multi_* functions.

The key thing here is that $ch is an individual handle that you keep track of. So curl_getinfo($ch[$key], CURLINFO_EFFECTIVE_URL); would be a possible implementation if $ch was an array of curl handles.

goat
  • 31,486
  • 7
  • 73
  • 96
  • While playing around some more, I noticed that `curl_getinfo($ch[$key])` was returning the normal array of info, but because I have most of the return options turned off I didn't notice that the url wasn't coming back either--which led me to discover that I wasn't even initializing the URLs correctly in the first place. It works now, thanks so much! – Lorien Brune Jul 21 '12 at 01:18
0
CURLINFO_EFFECTIVE_URL

This paramter is not reliable for referencing your original url list. It can return a different url from from the url provided in CURLOPT_URL.

cecilli0n
  • 457
  • 2
  • 9
  • 20