Yii Framework Forum: How to store multiple cookies through PHP Curl - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to store multiple cookies through PHP Curl Rate Topic: -----

#1 User is offline   Blue Sapphire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 27-February 10

Posted 18 April 2010 - 10:49 AM

'SOUP.IO' is not providing any api. So Iam trying to use 'PHP Curl' to login and submit data through PHP.

Iam able to login the website successfully(through cUrl), but when I try to submit data through cUrl, it gives me error of 'invalid user'.

When I tried to analysed the code and website, I came to know that cUrl is getting values of only 1-2 cookies. Where as when I open the same page in FireFox, it shows me 6-7 cookies related to 'SOUP.IO'.

Can some one guide me how to get all these 7 cookies values.

Following cookies are getable by cUrl:

soup_session_id

Following cookies are shown in Firefox (not through cUrl):
__qca, __utma, __utmb, __utmc, __utmz

Following is my cUrl code:


<?php 
session_start(); 
 
$cookie_file_path = getcwd()."/cookie/cookie.txt"; 
 
$ch = curl_init(); 
 
curl_setopt($ch, CURLOPT_URL, 'http://www.soup.io'); 
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 
 
curl_setopt($ch, CURLOPT_HEADER, TRUE); 
 
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); 
 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); 
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); 
 
 
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) FirePHP/0.4'); 
 
 
curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
 
 
$result = curl_exec($ch); 
 
curl_close($ch); 
 
 
print_r($result); 
?> 



Can some one guide me in this regards

Thanks in advance
0

#2 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 18 April 2010 - 11:51 AM

__qca, __utma, __utmb, __utmc, __utmz


These cookies are set by Google Analytics thru JavaScript.

Regarding your login problem: Install some network analyzer like Wireshark in order to see the exact data send to soup.io. First use your browser, then your script. Now you can compare and see what's wrong.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users