473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Curl and file_get_contents returns 404 even if url is valid?

check www.onluna.com/test_curl.php . i used file_get_contents() to retrieve data from a url but it only returns :

failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in

the strangest thing is if i type the url im trying to open(you can see on the warning)
i get the right result so the file is definitely there. is this a problem with my hosting service? am i being block by the designated url server?

cant think of any other possible error,

appreciate for any help
Aug 20 '09 #1
6 9736
Markus
6,050 Expert 4TB
Can we see the code please?
Aug 20 '09 #2
Dormilich
8,658 Expert Mod 8TB
it’s possible to selectively block certain User Agents (can be done in Apache and most server side languages).
Aug 20 '09 #3
here's the code....


Expand|Select|Wrap|Line Numbers
  1. /*
  2. $ch = curl_init ('http://www.templatemonster.com/webapi/categories.php?login=onluna&webapipassword=dc1baa3ffc98008920ff8f90a7a4c40d&linebreak=,&delim=:&/');
  3. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  4. $result = curl_exec ($ch);
  5. curl_close ($ch);
  6. */
  7.  
  8. $result = file_get_contents('http://www.templatemonster.com/webapi/categories.php?login=onluna&webapipassword=dc1baa3ffc98008920ff8f90a7a4c40d&linebreak=,&delim=:&/');
  9. echo $result;


just a simple use of file_get_contents...the commented block is the curl part which also failed, initially i thought that it was the curl version that might have change from my hosting side..but after also failing with file_get_contents() i know its not the curl library...ive tried on 3 hosting each has failed except for one.:

1. www.onluna.com/test_curl.php
2. http://lunaclient.com/test_curl.php
3. www.jhabu.com/test_curl.php (this one worked)

what kind of server configuration might have caused a 404 for the same methods of accessing?? why would anyone block a certain agent? and is it based on ip?

info for server configuration:

1. http://onluna.com/info.php
2. http://jhabu.com/info.php
3. http://lunaclient.com/php_info.php


im quiet perplexed by this...thank you for any insight
Aug 20 '09 #4
Dormilich
8,658 Expert Mod 8TB
@everybytescount
for instance a missing request parameter.

@everybytescount
why should this anyone serve websites for something other than browsers?

note: that’s what I usually do, if my script finds that the User Agent is not capable of displaying my website, I send a 406 error.

@everybytescount
maybe
Aug 20 '09 #5
Markus
6,050 Expert 4TB
It works fine from my server.
Aug 20 '09 #6
@everybytescount
======

Have you got solution to this issue. I m facing same issue
Apr 9 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: mrbog | last post by:
1. In order to make an http (or https) request with PHP, I need to recompile php with cURL. 2. In order to install CURL I have to upgrade my openssl rpm, even though I'm runing a version of...
3
by: Chris Fortune | last post by:
# uname -a Linux stargate.mxc-online.net 2.4.20-021stab022.2.777-smp #1 SMP Wed Jul 28 17:12:37 MSD 2004 i686 i686 i386 GNU/Linux I recompiled PHP with mcrypt, openssl, and curl phpinfo():...
3
by: mahbubur045 | last post by:
I am little new in php environment. For one of my project I tried to do http communication(e.g XML message exchange) in php using cURL. is ther any limitaion/problem/overhead using php/curl for...
0
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one......
4
by: Terry | last post by:
I'm using curl to invoke a php script on the same site/server. It works great, but if I call it again while it's still running, nothing happens. Why? Can that be fixed? Why use curl? To make...
3
by: JDS | last post by:
So, I'd like to create the following scenario: 1) Use cURL library within PHP (cURL + "Cookie Jar", et.al) to create a virtual browser session that "logs in" to a remote site. (For example: ...
3
by: Erwin Moller | last post by:
Hi all, I want to create an URL to use with fopen($url). The URL needs basic authentication, but I have no CURL on this particular machine. (I need to access an app that uses REST.) I tried...
3
by: Sarah | last post by:
I was wondering if someone might be able to help me with this issue. I have a feeling this has something to do with my host's server settings as I used to be able to get CURL to follow redirects by...
3
by: jeddiki | last post by:
Out of these, which one do you use most and why ? fsockopen, curl, fopen, file_get_contents,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.