Get PHP CURL Final IP (ip url)

0 Cevap php

I'd like to get the final IP CURL ends on after executing a request. I would have presumed such a thing would be coming from curl_getinfo(), but as far as I could see, there's nothing like that (other than the final "effective URL"). Is there some way to do this?

Ben yaşadım bir fikir gibi bir şey yapmak oldu:

  // assumes $ch is the curl handle after curl_exec() but before curl_close()
  $finalurl = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
  $domain = parse_url( $finalurl, PHP_URL_HOST );
  $ip=gethostbyname( $domain );

Bu doğru ve de daha iyi bir şekilde bazı şüpheleri sahip olarak ise, ancak, benim şüphelerim var.

Lütfen dikkat:

  • Ben oldukça bir bağlantı değil, iki (ya da daha iyi, 0 ;-) şaka) olurdu
  • CURL olmadan, HTTP 1.0 ve yönlendirmeler yoluma ayrıştırmak gerekiyor

Ancak ben çok önemli bir şey eksik hissi duyuyorum ...

0 Cevap