Zend Framework中httpClient中的cookie问题

我在Zend框架中创建httpClient以进行页面请求。
我正在尝试添加cookie但它没有 似乎根据我得到的数据工作。 你能告诉我我做错了吗?</ p>

  $ httpClient = new HttpClient(); 
$ httpClient-&gt; setConfig
(array(
'timeout) '=&gt; 30,
'useragent'=&gt;“Opera / 9.80(Windows NT 5.1; U; ru)版本/ 10.62”,
'adapter'=&gt;'Zend_Http_Client_Adapter_Curl',
'curloptions'= &gt; array

CURLOPT_TIMEOUT =&gt; 30,
CURLOPT_FRESH_CONNECT =&gt; true,
),
));

$ httpClient-&gt; setCookieJar();

$ cookie = Zend_Http_Cookie :: fromString('abc = 1000;'+
'domain = .abc.ru;'+
'path = /;'+
'expires = Wednesday,28-Feb-12 20: 41:22 UTC');
$ httpClient-&gt; setCookie($ cookie);
</ code> </ pre>
</ div>

展开原文

原文

I create the httpClient in Zend framework to make page requests. I am trying to add a cookie but it does not seem to work according to the data which I get. Can you please tell me what am I doing wrong?

$httpClient = new HttpClient();
$httpClient->setConfig 
(array(
    'timeout'     => 30, 
    'useragent'   => "Opera/9.80 (Windows NT 5.1; U; ru)Version/10.62",
    'adapter'     => 'Zend_Http_Client_Adapter_Curl', 
    'curloptions' => array 
    (
        CURLOPT_TIMEOUT          => 30,
        CURLOPT_FRESH_CONNECT    => true,
    ),
));


$httpClient->setCookieJar();

$cookie = Zend_Http_Cookie::fromString('abc=1000; ' +
                                       'domain=.abc.ru; ' +
                                       'path=/; ' +
                                       'expires=Wednesday, 28-Feb-12 20:41:22 UTC');
$httpClient->setCookie($cookie);

1个回答



您不能在PHP中使用加号连接字符串:</ p>

 'abc = 1000  ;  '+ 
'domain = .abc.ru; '+
'path = /; '+
'expires =星期三,28-Feb-12 20:41:22 UTC'
</ code> </ pre>

加号是算术运算符,此语句只会导致' 0' 。 使用 '。' 运营商。</ p>
</ div>

展开原文

原文

You cannot join strings with plus sign in PHP:

'abc=1000; ' +
'domain=.abc.ru; ' +
'path=/; ' +
'expires=Wednesday, 28-Feb-12 20:41:22 UTC'

Plus sign is arithmetic operator and this statement simply results in '0'. Use '.' operator.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问