Jump to content

PHP/Curl Myspace Login Script


Bio

Recommended Posts

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>";
}

?> 

Link to comment
https://forums.phpfreaks.com/topic/196172-phpcurl-myspace-login-script/
Share on other sites

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>";
}

?> 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.