php curl sorun

2 Cevap php

Ben kıvrılma ile uzaktan dosya bilgi almak için çalışıyorum. Problem diğer web-server port 81 üzerinde olmasıdır.

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt ($ch, CURLOPT_PORT , 81);
curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185/server_status2.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);
?>

Ve gördüğünüz gibi çalışmıyor.

2 Cevap

Eğer URI port numarasını belirtmeniz durumunda ne olur?

Ne demek ilk CURLOPT_PORT satırını kaldırın ve daha sonra, port numarası eklemek için CURLOPT_URL birini değiştirmek olduğunu:

curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185:81/server_status2.php');


Edit after the comment : I just tryied this portion of code :

$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
//curl_setopt ($ch, CURLOPT_PORT , 81);
curl_setopt($ch, CURLOPT_URL, 'http://98.246.25.185:81/server_status2.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);

Ve ben bu çıktıyı alıyorum:

Online Peak: 59
Online: 17
Distributive server: Online
Agent server: Online

Yani, kod Tamam gibi görünüyor.

Are you sure there is not a firewall or anything or your network, that prevents you from doing HTTP requests on port 81 to that server ?
Does it work when you type that URI in your browser ?

Orijinal kod benim için çalışıyor. İade:

<b>Online Peak: </b>59        <br /><b>Online: </b> 17<br /><b>Distributive server:</b> <font color=green>Online</font><br /><b>Agent server:</b> <font color=green>Online</font><br />

Belki de liman güvenlik duvarı tarafından bloke ediliyor?

P.S. The echo in your code is redundant. The curl_exec prints the result to the output buffer unless you set CURLOPT_RETURNTRANSFER as TRUE.