Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Curl on 81 port

Tags:

php

curl

port

xampp

I have locally set 2 Apache Server on Port 80 and port 81 using XAMPP. Iam successfully able to access them through my browser. Currently the URL can be accessed at

http://27.4.198.225/ncmsl/check.php 

and

http://27.4.198.225:81/ncmsl/check.php. 

When I try to write a simple curl code for them

$ch=curl_init();                    
$url = "http://27.4.198.225/ncmsl/check.php";
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
curl_close($ch);

It works perfectly fine for server at port 80 but doesn't work for server at port 81, i.e.

$ch=curl_init();                    
$url = "http://27.4.198.225:81/ncmsl/check.php";
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_URL, $url);
curl_exec($ch);
curl_close($ch);

What could be the possible reason? I have tried using CURLOPT_PORT but that also doesn't work

These URL are LIVE URL. Can anybody check whether they are successfully able to access them using thei own CURL code on their own network

like image 492
Gunjan Nigam Avatar asked Sep 06 '12 09:09

Gunjan Nigam


1 Answers

Try this

curl_setopt ($ch, CURLOPT_PORT , 81);

Update code:-

see this URL:- php curl problem

$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL, 'http://27.4.198.225:81/ncmsl/check.php');
$store = curl_exec ($ch);
echo substr($store, 1);
curl_close ($ch);
like image 146
Abid Hussain Avatar answered Sep 20 '22 15:09

Abid Hussain