cURL to link gmail & youtube account ..I'll PAY if needed :]

Discussion in 'PHP' started by izzy_affiliate, Jan 5, 2009.

  1. #1
    Hello guys and girls of DP,

    I am trying to link a gmail account and youtube account with cURL and php.

    Process is like this:

    1. Go to LINK and sign in with gmail [This I can do ;) ]
    LINK = "https://www.google.com/accounts/ServiceLogin?service=youtube&continue=http://www.youtube.com/signup&passive=true"

    Code:
    <?php
    
    $email = 'ksandray29'; // without @gmail.com just username
    $pass= '29sandray';
    $post_data='continue=http%3A%2F%2Fwww.youtube.com%2Fsignup&service=youtube&Email='.$email.'&Passwd='.$pass.'&rmShown=1&signIn=Sign+in&asts=';
    $cookie = 'tmp/yt-cookie.txt'; 
    $url = 'https://www.google.com/accounts/ServiceLoginAuth?service=youtube';
    $referer = 'https://www.google.com/accounts/ServiceLogin?service=youtube&continue=http://www.youtube.com/signup&passive=true';
    $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)';
    
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5);       
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $result = curl_exec ($ch);
    curl_close ($ch);
    
    
    Code (markup):
    2. Then after some redirects, I arrive to a page where I have to sign in with youtube account. [This I can't do...]

    include("LIB_parse.php");
    $parsed_title = return_between($result, "<title>", "</title>", EXCL);
    echo $parsed_title;
    ?>
    Code (markup):
    When I try to parse the image between '<title>' and '</title>' I get the message "Redirecting", so I don't "arrive" to the youtube sign in page.. :/

    Any help will be appreaciated from the bottom of my heart :)
    Or I can also give a couple of domain or pay for your hosting or pay some cash.;)



    This would be the code I would use once I get to the Youtube Sign In page:
    include("LIB_parse.php");
    
    $parsed_auth = return_between($result, "&auth=", "\">", EXCL);
    $url = 'http://www.youtube.com/signup?auth='.$parsed_auth;
    $referer= 'http://www.youtube.com/signup?auth='.$parsed_auth;
    $cookie = 'tmp/yt-cookie.txt'; 
    $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)';
    
    $gmail_user = 'sandray29';
    $yt_user = 'sandray29';
    $yt_pass = '29sandray';
    
    $parsed_gcred = return_between($result, '<input type="hidden" name="gcred" value="', '" />', EXCL);
    $parsed_gtok = return_between($result, "<input type=\"hidden\" name=\"gtok\" value=\"", "\" />", EXCL);
    $parsed_session_token = return_between($result, "session_token=", "';", EXCL);
    
    $post_data = 'current_form=loginForm&gcred='.$parsed_gcred.'&gtok='.$parsed_gtok.'&gemail='.$gmail_user.'%40gmail.com&username='.$yt_user.'&password='.$yt_pass.'&action_login=Log+In&session_token='.$parsed_session_token;
    
    $sh = curl_init(); 
    curl_setopt($sh, CURLOPT_URL, $url);
    curl_setopt($sh, CURLOPT_RETURNTRANSFER, TRUE);  
    curl_setopt($sh, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($sh, CURLOPT_MAXREDIRS, 10);       
    curl_setopt($sh, CURLOPT_REFERER, $referer);
    curl_setopt($sh, CURLOPT_USERAGENT, $agent);
    curl_setopt($sh, CURLOPT_COOKIEFILE, $cookie);
    curl_setopt($sh, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt($sh, CURLOPT_POST, 1);
    curl_setopt($sh, CURLOPT_POSTFIELDS, $post_data);
    $resultado= curl_exec ($sh);
    curl_close ($sh);
    echo $resultado;
    ?>
    Code (markup):
     
    izzy_affiliate, Jan 5, 2009 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Might want to remove your password...
     
    Danltn, Jan 6, 2009 IP
  3. izzy_affiliate

    izzy_affiliate Peon

    Messages:
    162
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    no problem is just a disposable youtube account, LOL. ;)
     
    izzy_affiliate, Jan 6, 2009 IP
  4. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #4
    I didn't get it. Do you want to login to youtube using google account or what?
     
    chmdznr, Jan 6, 2009 IP
  5. izzy_affiliate

    izzy_affiliate Peon

    Messages:
    162
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    hi,
    what i want to do is link gmail and youtube account.
    In here:
    http://www.google.com/support/youtube/bin/answer.py?hl=en&answer=69964
    They give a link to sign in with gmail then you are redirected like 3 times and then you have to sign in with youtube account. After that gmail is linked to youtube account.

    Anybody can make the script work, I will pay for it with paypal.
     
    izzy_affiliate, Jan 6, 2009 IP
  6. chmdznr

    chmdznr Active Member

    Messages:
    417
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #6
    Ha? What do you mean?
     
    chmdznr, Jan 7, 2009 IP
  7. atlantaazfinest

    atlantaazfinest Peon

    Messages:
    389
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Job is done.!
     
    atlantaazfinest, Jan 7, 2009 IP