Hello

I want to get response or content of a url..!!!

$url="http://203.142.18.33:4480/3030service/airtel.php?mobile=".$mobile."&msg=".$msg."&from=".$from;
  $file=file($url) ;
  print_r($file);

but i got an error [function.file]: failed to open stream: HTTP request failed- Response of the file..!!

with file_get_contents it showing same error..!!

is there any method other to get the response..!!
with
thank u.!

Recommended Answers

All 5 Replies

Hello

I want to get response or content of a url..!!!

$url="http://203.142.18.33:4480/3030service/airtel.php?mobile=".$mobile."&msg=".$msg."&from=".$from;
  $file=file($url) ;
  print_r($file);

but i got an error [function.file]: failed to open stream: HTTP request failed- Response of the file..!!

with file_get_contents it showing same error..!!

is there any method other to get the response..!!
with
thank u.!

What you have paste here - " failed to open stream: HTTP request failed- Response of the file..!!" is a server response.

Please paste complete error message.

What you have paste here - " failed to open stream: HTTP request failed- Response of the file..!!" is a server response.

Please paste complete error message.

file([url]http://203.142.18.33:4480/3030service/airtel.php?mobile=xxxxx&msg=xxxx&from=xxxx[/url]) [function.file]: failed to open stream: HTTP request failed! [U][I]Hello how r u..?[/I].[/U] in C:\xampp\htdocs\sms\sms1.php on line 8

Underlined text is a Message or Response or Content of a Url..!!

if i run url directly on browser than it perfectly showing the content..!!

but using php it throwing error..!! :(

thnx for quick response

Is 203.142.18.33 your IP?

If so then you need to use the localhost IP (127.0.0.1).

Else I would look into fsockopen.

Hi.

Have you made sure your server allows URLs to be used to get data like that?
Try this:

<?php
    header("content-type: text/plain");
    echo "fopen  : ", (ini_get('allow_url_fopen') ? "TRUE" : "FALSE"), "\n";
    echo "include: ", (ini_get('allow_url_include') ? "TRUE" : "FALSE"), "\n";
?>

If both are FALSE, then your server doesn't allow this.
If only fopen is TRUE, then you should be able to use the file or file_get_contents (and obviously fopen ) functions to open URLs.

In that case, there is something else going on.
Try printing the exact URL being used, see if it is somehow malformed after being manipulated by PHP.

Hi.

Have you made sure your server allows URLs to be used to get data like that?
Try this:

<?php
    header("content-type: text/plain");
    echo "fopen  : ", (ini_get('allow_url_fopen') ? "TRUE" : "FALSE"), "\n";
    echo "include: ", (ini_get('allow_url_include') ? "TRUE" : "FALSE"), "\n";
?>

If both are FALSE, then your server doesn't allow this.
If only fopen is TRUE, then you should be able to use the file or file_get_contents (and obviously fopen ) functions to open URLs.

In that case, there is something else going on.
Try printing the exact URL being used, see if it is somehow malformed after being manipulated by PHP.

You'd actually get a different error if allow_url_fopen was set to false.

The url cannot be accessed in a browser:
http://203.142.18.33:4480/

Are you sure the URL is working? Unless they only allow certain IPs to connect to that port, the URL is down.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.