Bio Posted March 22, 2010 Share Posted March 22, 2010 Finding a working script to achieve this task has proven pointless. I have found several examples but have yet to find one that works. I started using PHP several months ago and have been able to do alot of the content gathering by using snoopy but some features on myspace require you to be signed in. I do not want to spam, or even post anything to myspace. I am solely interested in gathering information (stats specifically) from Myspace Apps. I have just begun to look at Curl and I certainly believe its capable of it but every script i find (as recently as February 2010) dont work or gives this error: Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/a1242578/public_html/myspace_login.php on line 16 line 16 is: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); php.net says this is redundant because Curl will follow all redirects unless directed otherwise but if i comment it out, i get no error but i get no output either. PHP is NOT running in safe more. What else could cause this error? Is line 16 required or should it work without it? Here is the script in its entirety, found on this site. <?php class Myspace { function login($username, $password) { $username = $_POST['user']; $password = $_POST['passwd']; $login_url = "https://secure.myspace.com/index.cfm?fuseaction=login.process"; $post_data = "ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24Email_Textbox=$username&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24Password_Textbox=$password"; $ch = curl_init($login_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $login_url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) "); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data); $result = curl_exec($ch); curl_close($ch); echo $result; } } if($_POST['user'] && $_POST['passwd']) { $login = new Myspace; echo $login->login($_POST['user'],$_POST['passwd']); } else { echo "<html> <body> <form action='myspace_login.php' method='POST'> <input type='text' name='user' /><br /> <input type='password' name='passwd' /><br /> <input type='submit' value='submit' /> </form> </form> </body> </html>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/196172-phpcurl-myspace-login-script/ Share on other sites More sharing options...
MadTechie Posted March 22, 2010 Share Posted March 22, 2010 Adding curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); should fix the problem Quote Link to comment https://forums.phpfreaks.com/topic/196172-phpcurl-myspace-login-script/#findComment-1030211 Share on other sites More sharing options...
Bio Posted March 22, 2010 Author Share Posted March 22, 2010 No change in execution or output that i could see. Thanks tho! Im sure its a step closer! Quote Link to comment https://forums.phpfreaks.com/topic/196172-phpcurl-myspace-login-script/#findComment-1030212 Share on other sites More sharing options...
MadTechie Posted March 22, 2010 Share Posted March 22, 2010 I just tried it and it seams fine on my local machine, (are you sure its not in safe mode) also check what open_basedir is set to My text script <?php class Myspace { function login($username, $password) { $username = $_POST['user']; $password = $_POST['passwd']; $login_url = "https://secure.myspace.com/index.cfm?fuseaction=login.process"; $post_data = "ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24Email_Textbox=$username&ctl00%24ctl00%24cpMain%24cpMain%24LoginBox%24Password_Textbox=$password"; $ch = curl_init($login_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $login_url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) "); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); $result = curl_exec($ch); curl_close($ch); echo $result; } } if($_POST['user'] && $_POST['passwd']) { $login = new Myspace; echo $login->login($_POST['user'],$_POST['passwd']); } else { echo "<html> <body> <form action='' method='POST'> <input type='text' name='user' /><br /> <input type='password' name='passwd' /><br /> <input type='submit' value='submit' /> </form> </form> </body> </html>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/196172-phpcurl-myspace-login-script/#findComment-1030265 Share on other sites More sharing options...
Bio Posted March 23, 2010 Author Share Posted March 23, 2010 Ill try it on my local box and see whats happens - i have been working with it on my web server. Quote Link to comment https://forums.phpfreaks.com/topic/196172-phpcurl-myspace-login-script/#findComment-1030277 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.