cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Get the User-Agent string?

From: Andrey Kuznetsov <kandrey89_at_gmail.com>
Date: Thu, 11 Nov 2010 12:54:44 -0800

I think you might be confusing curl.

You use curl to specify the url, request type, and other header fields
like user agent, and etc.
The webpage that receives the request, suppose its a php script will
get this data, then if you want the webpage to parse the useragent,
then access this variable which will be set based on the information
sent to it by the curl, $_SERVER['HTTP_USER_AGENT'].

I believe you can set ANY useragent field you want, there is no strict
format, especially since it seems like you want to use it for
yourself, so there probably won't be an outside incompatibilities.

Basically, you should be able to do this:
curl_setopt($ch, CURLOPT_USERAGENT, 'Hello World, This is My NEW
USERAGENT string, it is custom made');

then when the page receives the request from curl, this variable will be =>
$_SERVER['HTTP_USER_AGENT'] == 'Hello World, This is My NEW USERAGENT
string, it is custom made'

On Thu, Nov 11, 2010 at 12:32 PM, Tom Worster <fsb_at_thefsb.org> wrote:
> Curl does things like this:
>
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7
> OpenSSL/0.9.8l zlib/1.2.3
> Host: 127.0.0.1:12345
> Accept: */*
>
>
> That's a swell User-Agent value. Very informative.
>
> In my application, I want to send an informative User-Agent such as this
> but modified to identify also my application. Hence I want to find the
> proper UA string for the php curl instance on the server so that I can
> manipulate it.
>
> So can I read such a string value in a PHP script?
>
> On other words: We are given a UA setter curl_setopt(,
> CURLOPT_USERAGENT,). Is there a corresponding UA getter?
>
> Tom
>
>
> On 11/11/10 3:02 PM, "Andrey Kuznetsov" <kandrey89_at_gmail.com> wrote:
>
>>You are unclear about what you mean, sending HTTP GET to oneself, what
>>does that mean?
>>
>>If you want to send the useragent of the browser that is running the
>>script the use $_SERVER['HTTP_USER_AGENT'] value.
>>
>>On Thu, Nov 11, 2010 at 11:54 AM, Tom Worster <fsb_at_thefsb.org> wrote:
>>> We can set the User-Agent string that cURL will use with
>>>
>>>  curl_setopt($handle, CURLOPT_USERAGENT, 'Something');
>>>
>>> But is there a way to get this this string value without sending an HTTP
>>> GET to oneself?
>>>
>>> Tom
>>>
>>>
>>> _______________________________________________
>>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>>
>>
>>
>>
>>--
>>Andrey
>>_______________________________________________
>>http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>

-- 
Andrey
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-11-11