tags:

views:

404

answers:

3

'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

+1  A: 

These extra "underscore" cookies seem like Google Analytics or similar tracking cookies, most likely set via Javascript. That's the reason they don't show up when using cURL. I'd venture the guess that they're not the problem.

deceze
I have checked/analysed these cookies. I found that they are used in the process. So PHP cUrl can get values of these javascript generated cookies.
Ahmad
@Ahmad If these cookies are indeed generated by Javascript and if they really are essential to the operation, I'm afraid you're fresh out of luck. You'd basically need to emulate a whole Javascript capable browser. If they're not offering an API, you should probably stop what you're doing anyway.
deceze
i agree, atleast 4 of them are tracking cookies, if you have firefox just disable javascript and see it those cookies get set. i think you only cookie that actually matters in this case is the "soup_session_id"
Sabeen Malik
@Sabeen you are right, but I think ,there are three 'soup.session_id', 'soup_user_id', 'soup_video_ad' .Iam able to login after disabling javascript. I have posted my code after login, can you guide me where Iam going wrong.Sorry for visiting your website, but I have to accept one thing that you know cUrl much better than myself. Thanks in advance
Ahmad
A: 

A couple of things i noticed once i signup and went into the area. The domain all my action happens is "user.soup.io" and not "www.soup.io" , that could be the reason behind your invalid user error. Try to set the url to your own subdomain AFTER the login is complete and see how it goes. Also what data are you exactly trying to post?

This may not be relevant but soup.io doesnt seem to use HTTPS, so why use:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
Sabeen Malik
A: 

Here is my curl code which Iam trying to use for sending data to soup.io after suceesful login through cUrl $storedata = array(); $storedata["post[title]"] = 'Phoonk 2 (16th April 2010)'; $storedata["post[body]"] = 'Ramgopal Varma\'s love for horror and supernatural continues. This time, in PHOONK 2, the team behind PHOONK promise more chills, more thrills and more screams. But what you get to hear at the end of the screening is a moan, since PHOONK 2 lacks the chills, thrills and screams that were the mainstay of its first part.'; $storedata["post[tags]"] = 'Bollywood Movie, Indian movie'; $storedata["commit"] = 'Save'; $storedata["post[id]"] = ''; $storedata["post[type]"] = 'PostRegular'; $storedata["post[parent_id]"] = ''; $storedata["post[original_id]"] = ''; $storedata["post[edited_after_repost]"] = ''; $store_post_str = ''; foreach($storedata as $key => $value){ $store_post_str .= $key.'='.urlencode($value).'&'; } $store_post_str = substr($store_post_str, 0, -1);

$ch2 = curl_init();

curl_setopt($ch2, CURLOPT_URL, 'http://loekit.soup.io/save'); curl_setopt($ch2, CURLOPT_VERBOSE, 1);

curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch2, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch2, CURLOPT_HEADER, TRUE);

curl_setopt($ch2, CURLOPT_ENCODING, 'gzip,deflate');

//curl_setopt($ch2, CURLOPT_COOKIEJAR, $cookie_file_path); //curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie_file_path);

curl_setopt($ch2, CURLOPT_REFERER, 'http://loekit.soup.io/'); curl_setopt($ch2, 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($ch2, CURLOPT_MAXREDIRS, 10); curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch2, CURLOPT_POSTFIELDS, $store_post_str); curl_setopt($ch2, CURLOPT_POST, TRUE);

Ahmad
can you format this a bit better .. better yet .. move it to the original question
Sabeen Malik