<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Help with curl</title>
	<link>http://ask.metafilter.com/83745/Help-with-curl/</link>
	<description>Comments on Ask MetaFilter post Help with curl</description>
	<pubDate>Fri, 15 Feb 2008 15:39:46 -0800</pubDate>
	<lastBuildDate>Fri, 15 Feb 2008 15:39:46 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Help with curl</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl</link>	
		<description>Curl response different than browser &lt;br /&gt;&lt;br /&gt; This was working great until this afternoon, not sure what to do.&lt;br&gt;
When I use this code:&lt;br&gt;
&lt;br&gt;
http://grady.us/apps/liz/test.txt&lt;br&gt;
&lt;br&gt;
http://grady.us/apps/liz/test&lt;br&gt;
&lt;br&gt;
The data it prints out is: &lt;br&gt;
&lt;br&gt;
HTTP/1.1 200 OK Date: Fri, 15 Feb 2008 23:09:04 GMT Server: IBM_HTTP_Server Surrogate-Control: content=&quot;ESI/1.0&quot; Content-Length: 9792 Set-Cookie: JSESSIONID=0000eh4Igf-Mqg5goa-lDy0GuRd:12qjgbb49; Path=/ Set-Cookie: Registration=currentUserId:; Expires=Wed, 13 Feb 2013 23:09:48 GMT; Path=/; Domain=cars.com Set-Cookie: affiliate=national; Expires=Fri, 07 Mar 2008 23:09:48 GMT; Path=/; Domain=cars.com Set-Cookie: zipcode=34205; Expires=Wed, 13 Feb 2013 23:09:48 GMT; Path=/; Domain=cars.com Set-Cookie: SessionInfo=mkid%3D34%7Cmknm%3DMitsubishi%7Cmdid%3D314%7Cmdnm%3DMontero%7C; Expires=Wed, 13 Feb 2013 23:09:48 GMT; Path=/; Domain=cars.com Content-Type: text/html Content-Language: en-US Set-Cookie: cars_persist=3745585324.20480.0000; expires=Fri, 15-Feb-2008 23:38:31 GMT; path=/ Vary: Accept-Encoding&lt;br&gt;
cars.com logo&lt;br&gt;
Looking for something on cars.com?&lt;br&gt;
&lt;br&gt;
Sorry, the page you requested is not available. Some linked or bookmarked pages may have moved. If you are not redirected to the cars.com homepage in a few seconds, please click here.[/quote]&lt;br&gt;
&lt;br&gt;
It is able to set cookies and the cookies it sets:&lt;br&gt;
&lt;br&gt;
# Netscape HTTP Cookie File&lt;br&gt;
# http://www.netscape.com/newsref/std/cookie_spec.html&lt;br&gt;
# This file was generated by libcurl! Edit at your own risk.&lt;br&gt;
&lt;br&gt;
www.cars.com	FALSE	/	FALSE	0	JSESSIONID	0000eh4Igf-Mqg5goa-lDy0GuRd:12qjgbb49&lt;br&gt;
.cars.com	TRUE	/	FALSE	1360796988	Registration	currentUserId:&lt;br&gt;
.cars.com	TRUE	/	FALSE	1204931388	affiliate	national&lt;br&gt;
.cars.com	TRUE	/	FALSE	1360796988	zipcode	34205&lt;br&gt;
.cars.com	TRUE	/	FALSE	1360796988	SessionInfo	mkid%3D34%7Cmknm%3DMitsubishi%7Cmdid%3D314%7Cmdnm%3DMontero%7C&lt;br&gt;
www.cars.com	FALSE	/	FALSE	1203118711	cars_persist	3745585324.20480.0000&lt;br&gt;
&lt;br&gt;
If URL is set to simply http://www.cars.com/go/index.jsp, their home page, it works.&lt;br&gt;
Help?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.83745</guid>
		<pubDate>Fri, 15 Feb 2008 15:22:09 -0800</pubDate>
		<dc:creator>jesirose</dc:creator>
		
			<category>curl</category>
		
			<category>php</category>
		
	</item> <item>
		<title>By: rhizome</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl#1239818</link>	
		<description>Use Wireshark/tcpdump to snarf the outgoing requests to see if they are in fact identical.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.83745-1239818</guid>
		<pubDate>Fri, 15 Feb 2008 15:39:46 -0800</pubDate>
		<dc:creator>rhizome</dc:creator>
	</item><item>
		<title>By: jesirose</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl#1239825</link>	
		<description>Figures the client calls me as soon as I post this. I will have to google those and figure out what to do, this is really the first time I used Curl.&lt;br&gt;
Thanks!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.83745-1239825</guid>
		<pubDate>Fri, 15 Feb 2008 15:56:39 -0800</pubDate>
		<dc:creator>jesirose</dc:creator>
	</item><item>
		<title>By: RichardP</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl#1239880</link>	
		<description>An examination of the response from cars.com to your request indicates that cars.com is returning the contents out of order (some sort of buffering bug).  Fiddling with the request a bit, it appears that it is a language handling bug in the cars.com web server / web application.  If I modify your sample code to include an Accept-Langage header...&lt;blockquote&gt;&lt;code&gt;curl_setopt($ch, CURLOPT_HTTPHEADER, array(&quot;Accept-Language: en&quot;));&lt;/code&gt;&lt;/blockquote&gt;... I get a valid response from cars.com.&lt;br&gt;
&lt;br&gt;
By the way, spoofing the HTTP user agent to appear as if your request originates from Firefox is unnecessary and rather unfriendly.  If you&apos;re going to be generating automated queries to their site you should include a user agent that is unique to your application (possibly even including a URL or e-mail address at which they can contact you if your application places undue load on their servers).  For example, instead of...&lt;blockquote&gt;&lt;code&gt;$useragent=&quot;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1&quot;;&lt;/code&gt;&lt;/blockquote&gt;...I&apos;d recommend you use something like...&lt;blockquote&gt;&lt;code&gt;$useragent=&quot;CarsProgram/1.0 (+http://grady.us/apps/liz/bot.html)&quot;&lt;/code&gt;&lt;/blockquote&gt;And then put some explanatory text and contact information at http://grady.us/apps/liz/bot.html.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.83745-1239880</guid>
		<pubDate>Fri, 15 Feb 2008 17:00:43 -0800</pubDate>
		<dc:creator>RichardP</dc:creator>
	</item><item>
		<title>By: jesirose</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl#1239970</link>	
		<description>Thank you so much Richard P</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.83745-1239970</guid>
		<pubDate>Fri, 15 Feb 2008 18:52:31 -0800</pubDate>
		<dc:creator>jesirose</dc:creator>
	</item><item>
		<title>By: jesirose</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl#1239973</link>	
		<description>The reason I had set it to Firefox was that was the code I got off an example on how to accept cookies. Will the custom user agent still be able to accept cookies if I need to use this for other  projects?&lt;br&gt;
Thanks a ton, you saved my butt :)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.83745-1239973</guid>
		<pubDate>Fri, 15 Feb 2008 18:55:50 -0800</pubDate>
		<dc:creator>jesirose</dc:creator>
	</item><item>
		<title>By: RichardP</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl#1239998</link>	
		<description>&lt;i&gt;Will the custom user agent still be able to accept cookies if I need to use this for other projects?&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
Sure.  The user agent identifies the client to the server, it shouldn&apos;t interact with cookie handling at all.  The only case I can think of where it would matter is if the server did some really odd server side processing involving browser sniffing and cookies (i.e. set cookie A if client identifies itself as IE, but set cookie B if client identifies itself as Firefox).  Browser sniffing isn&apos;t unheard of, but I have never seen it used to determine which cookies will be by the server.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.83745-1239998</guid>
		<pubDate>Fri, 15 Feb 2008 19:23:13 -0800</pubDate>
		<dc:creator>RichardP</dc:creator>
	</item><item>
		<title>By: jesirose</title>
		<link>http://ask.metafilter.com/83745/Help-with-curl#1240007</link>	
		<description>Right, I have seen that too - good call. &lt;br&gt;
Thanks again and have a great evening!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.83745-1240007</guid>
		<pubDate>Fri, 15 Feb 2008 19:33:04 -0800</pubDate>
		<dc:creator>jesirose</dc:creator>
	</item>
	</channel>
</rss>
