'SOUP.IO'没有提供任何api。所以Iam尝试使用'PHP Curl'登录并通过PHP提交数据。
我能够成功登录网站(通过cUrl),但是当我尝试通过cUrl提交数据时,它给出了“无效用户”的错误。
当我试图分析代码和网站时,我发现cUrl只获得了1-2个cookie的值。当我在FireFox中打开同一页面时,它显示了与'SOUP.IO'相关的6-7个cookie。
有人可以指导我如何获得所有这7个Cookie值。
以下Cookie可由cUrl:
制作soup_session_id
以下Cookie在Firefox中显示(不是通过cUrl):
__qca,__ utma,__ utmb,__ utmc,__ utmz
以下是我的cUrl代码:
<?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);
?>
有人可以在这方面指导我吗
提前致谢
答案 0 :(得分:2)
这些额外的“下划线”Cookie看起来像Google Analytics或类似的跟踪Cookie,很可能是通过Javascript设置的。这就是他们在使用cURL时没有出现的原因。我冒昧地猜测他们不是问题。
答案 1 :(得分:0)
一旦我注册并进入该区域,我注意到了一些事情。我所有动作发生的域是“user.soup.io”而不是“www.soup.io”,这可能是导致无效用户错误的原因。尝试在登录完成后将URL设置为您自己的子域,并查看它是如何运行的。您还准确发布了哪些数据?
这可能不相关,但是soup.io似乎没有使用HTTPS,所以为什么要使用:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
答案 2 :(得分:0)
以下是我在尝试通过soup.io
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);