Solved

problem with the sd commmand when tring to make a cookie

Posted on 2008-10-09
1
232 Views
Last Modified: 2012-05-05
i am tring to make a cookie for a forum and to take a content ftom a thread
im using the command
curl_init();
now i get this problem
------------------------------------------------------------------------------------------------------------------------
HTTP/1.1 200 OK Transfer-Encoding: chunked X-Powered-By: PHP/5.2.6 Cache-Control: private, pre-check=0, post-check=0, max-age=0 Expires: 0 Pragma: no-cache Content-type: text/html Date: Thu, 09 Oct 2008 15:54:12 GMT Server: unknown
-------------------------------------------------------------------------------------------------------------
how can i fix this?

i am using this script to take the thread
please help


$ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, "http://forum.doom9.org/login.php");
         curl_setopt($ch, CURLOPT_HEADER, 1);
         curl_setopt($ch, CURLOPT_NOBODY, 0);
         curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "/cookies.txt");
         curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "/cookies.txt");
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, "username=user&password=sedr&action=login");
         curl_exec($ch);
 
	// use this to pull up the thread you want to grab content from
         curl_setopt($ch, CURLOPT_URL, "http://forum.doom9.org/");
         $result = curl_exec($ch);
		 echo $result;

Open in new window

0
Comment
Question by:mgtm3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 22684599
Not sure if you are having problems instantiaing a curl request or avoiding the header or what. There's  class here that may help you:
http://us3.php.net/manual/en/function.curl-exec.php#80442

IMPORTANT: Make sure you read the comment right above it too.

Here's how you would use that class:
$rq=new CurlRequest();
$params=array(
	'url'=>'http://forum.doom9.org/login.php'
	,'host'=>'forum.doom9.org'
	,'method'=>'POST'
	,'cookie'=> dirname($_SERVER['PHP_SELF']) .'/cookies.txt'
	,'timeout'=>0
	,'post_fields' => 'username=user&password=sedr&action=login'
);
$rq->init($params);
$result = $rq->exec();
echo $result['header'];//this is to print just the header
echo $result['body'];//this will print only the content

Open in new window

0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question