Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Twitter Login And Tweet

    I have a twitter login script how can i make it so when the person logs in it follow my account and tweet a message.

    twitter.php
    Code:
    <?php
    /**
     * twitter authentication script based on
     * pecl oauth extension
     */
    session_start();
    include_once("config.php");
    /*
    unset($_SESSION['trequest_token_secret']);
    unset($_SESSION['taccess_oauth_token']);
    unset($_SESSION['taccess_oauth_token_secret']);
     */
    $oauthc = new OAuth($oauth['twitter']['consumerkey'],
            $oauth['twitter']['consumersecret'],
            OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI); //initiate
    if(empty($_SESSION['trequest_token_secret'])) {
        //get the request token and store it
        $request_token_info = $oauthc->getRequestToken($oauth['twitter']['requesttokenurl']); //get request token
        $_SESSION['trequest_token_secret'] = $request_token_info['oauth_token_secret'];
        header("Location: {$oauth['twitter']['authurl']}?oauth_token=".$request_token_info['oauth_token']);//forward user to authorize url
    }
    else if(empty($_SESSION['taccess_oauth_token'])) {
        //get the access token - dont forget to save it 
        $request_token_secret = $_SESSION['trequest_token_secret'];
        $oauthc->setToken($_REQUEST['oauth_token'],$request_token_secret);//user allowed the app, so u
        $access_token_info = $oauthc->getAccessToken($oauth['twitter']['accesstokenurl']);
        $_SESSION['taccess_oauth_token']= $access_token_info['oauth_token'];
        $_SESSION['taccess_oauth_token_secret']= $access_token_info['oauth_token_secret'];
    }
    if(isset($_SESSION['taccess_oauth_token'])) {
        //now fetch current users profile
        $access_token = $_SESSION['taccess_oauth_token'];
        $access_token_secret =$_SESSION['taccess_oauth_token_secret'];
        $oauthc->setToken($access_token,$access_token_secret);
        $data = $oauthc->fetch('http://twitter.com/account/verify_credentials.json');
        $response_info = $oauthc->getLastResponse();
        echo "<pre>";
        print_r(json_decode($response_info));
        echo "</pre>";
    }
    ?>
    config.php
    Code:
    <?php
    $oauth['twitter']['consumersecret']="T6aEghCdbQKKrvpvK4J4VjV7AGFLNct6p*****Ig";
    $oauth['twitter']['consumerkey']="8Zjaoknz*******zsujw";
    $oauth['twitter']['requesttokenurl']="http://twitter.com/oauth/request_token";
    $oauth['twitter']['accesstokenurl']="http://twitter.com/oauth/access_token";
    $oauth['twitter']['authurl']="http://twitter.com/oauth/authorize";
    $oauth['linkedin']['consumersecret']="SX9FS_Ptz7yNA3WtTW0e8z3_XSiROnVSpOEbAVCfKAn7fqFq4kjelVXiNMO*****";
    $oauth['linkedin']['consumerkey']="qQkxCNYQbuALhWyBZO03V--6dtwUnQHz7KFE4PBpdIL6hy_87SHygEZAJj9*****";
    $oauth['linkedin']['requesttokenurl']="https://api.linkedin.com/uas/oauth/requestToken";
    $oauth['linkedin']['accesstokenurl']="https://api.linkedin.com/uas/oauth/accessToken";
    $oauth['linkedin']['authurl']="https://api.linkedin.com/uas/oauth/authorize";
    ?>
    Last edited by justfreebies; 08-07-2010 at 08:19 PM.

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    St George, UT
    Posts
    138
    Thanks
    6
    Thanked 17 Times in 17 Posts
    Are you sharing this or is there a question?

  • #3
    New to the CF scene
    Join Date
    May 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by wildreason View Post
    Are you sharing this or is there a question?
    How can i make it so when the person logs in with the app it makes there account follow me an tweet a message?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •