having problem with curl

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

having problem with curl

Post by itsmani1 »

I am having problem with curl, here is my code i want to fetch content of this page on my page. From the page i just want to fetch the search box. but its not working.

i i try this it works fine and shows me output.

Code: Select all

curl_setopt($ch, CURLOPT_URL, "http://www.google.com.pk");
not in this case.

Code: Select all

header("Cache-control: private, no-cache");
	header("Expires: 0");
	header("Pragma: no-cache");
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_URL, "https://www.kulula.com/Default.aspx");
	curl_setopt ($ch, CURLOPT_COOKIEJAR, "tmp.txt");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	echo curl_exec($ch);	
	curl_close($ch);
Output:

Object moved to here.


any help.
thank you
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The site uses a browser switch and cannot identify cUrl as a "valid" client.
Add

Code: Select all

curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 4);
and take a look at the output.
You can change the agent-string, see http://de2.php.net/manual/en/function.curl-setopt.php

p.s.: make sure you have permissons to access the site in this way.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

thanks i have done it and its working now,
permissions are available.
Post Reply