Quantcast

Zend_Http_Client

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Zend_Http_Client

Olivier Ricordeau
Hi list,

I'm looking for a way of setting the prefered languages in a
Zend_Http_Client. I'd like to be able to say "fr" for instance, so that
my client gets the content in French.
I'm setting up a search engine and I'd like my crawler.php script to
index the web site in every language available (the website is
multi-lingual thanks to Zend_Translate, the language detection is based
on which prefered languages the client sends).

Cheers,
Olivier

--
- *Olivier RICORDEAU* -
  [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Zend_Http_Client

Olivier Ricordeau
Olivier Ricordeau a écrit :
> Hi list,
>
> I'm looking for a way of setting the prefered languages in a
> Zend_Http_Client. I'd like to be able to say "fr" for instance, so that
> my client gets the content in French.
> I'm setting up a search engine and I'd like my crawler.php script to
> index the web site in every language available (the website is
> multi-lingual thanks to Zend_Translate, the language detection is based
> on which prefered languages the client sends).

FYI, I've tried this:
// Set up Zend_Http_Client
$client = new Zend_Http_Client();
$client->setConfig(array('timeout' => 30));
$client->setParameterPost('language', 'fr');

Which results in:
Fatal error: Uncaught exception 'Zend_Http_Client_Exception' with
message 'Cannot handle content type '' automatically. Please use
Zend_Http_Client::setRawData to send this kind of content.' in
/home/olivier/public_html/ZendFramework-1.0.3/library/Zend/Http/Client.php:953
Stack trace:
#0
/home/olivier/public_html/ZendFramework-1.0.3/library/Zend/Http/Client.php(754):
Zend_Http_Client->prepare_body()
#1 /home/olivier/public_html/hypios-main/scripts/crawler.php(62):
Zend_Http_Client->request()
#2 {main}
   thrown in
/home/olivier/public_html/ZendFramework-1.0.3/library/Zend/Http/Client.php
on line 953

This exception is thrown at the following line:
$response = $client->request();

What can I do to make it work?

> Cheers,
> Olivier
>


--
- *Olivier RICORDEAU* -
  [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Zend_Http_Client

Olivier Ricordeau
Ok I found the answer. Here is the solution:

// Set up Zend_Http_Client
$client = new Zend_Http_Client();
$client->setConfig(array('timeout' => 30));
$client->setHeaders("Accept-Language", "fr");

Olivier

Olivier Ricordeau a écrit :

> Olivier Ricordeau a écrit :
>> Hi list,
>>
>> I'm looking for a way of setting the prefered languages in a
>> Zend_Http_Client. I'd like to be able to say "fr" for instance, so
>> that my client gets the content in French.
>> I'm setting up a search engine and I'd like my crawler.php script to
>> index the web site in every language available (the website is
>> multi-lingual thanks to Zend_Translate, the language detection is
>> based on which prefered languages the client sends).
>
> FYI, I've tried this:
> // Set up Zend_Http_Client
> $client = new Zend_Http_Client();
> $client->setConfig(array('timeout' => 30));
> $client->setParameterPost('language', 'fr');
>
> Which results in:
> Fatal error: Uncaught exception 'Zend_Http_Client_Exception' with
> message 'Cannot handle content type '' automatically. Please use
> Zend_Http_Client::setRawData to send this kind of content.' in
> /home/olivier/public_html/ZendFramework-1.0.3/library/Zend/Http/Client.php:953
>
> Stack trace:
> #0
> /home/olivier/public_html/ZendFramework-1.0.3/library/Zend/Http/Client.php(754):
> Zend_Http_Client->prepare_body()
> #1 /home/olivier/public_html/hypios-main/scripts/crawler.php(62):
> Zend_Http_Client->request()
> #2 {main}
>   thrown in
> /home/olivier/public_html/ZendFramework-1.0.3/library/Zend/Http/Client.php
> on line 953
>
> This exception is thrown at the following line:
> $response = $client->request();
>
> What can I do to make it work?
>
>> Cheers,
>> Olivier
>>
>
>


--
- *Olivier RICORDEAU* -
  [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Zend_Http_Client

pida
To rid of your error message in your code use:

<code>
$client->request("POST")
</code>

and also sending POST parameter language=fr should work fine.

Olivier Ricordeau wrote
// Set up Zend_Http_Client
$client = new Zend_Http_Client();
$client->setConfig(array('timeout' => 30));
$client->setParameterPost('language', 'fr')
Olivier
Loading...