post('statuses/update', array('status' => $_POST['tweet_text'] . ' ' . $_POST['tweet_link'])); // var_dump($postedtid); echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
Successfully Tweeted.
'; echo '
'; echo $wppwt_after_tweet; echo '
'; if ( isset($_GET['title']) AND $_GET['title'] != '' ) echo 'Now get ' . esc_attr($_GET['title']) . ' for free'; echo '
'; if ( isset($_GET['dl']) AND $_GET['dl'] != '' ) echo '' . $wppwt_button_title . ''; echo '
'; echo 'When you click ' . $wppwt_button_title . ', it will automatically close this window and redirect you to the URL link for downloading your files. Enjoy it! :)'; echo '
'; } else { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
Your Profile link: ' . $_SESSION['screen_name'] . '
'; echo stripslashes($wppwt_promotion); echo '
'; echo '
'; echo ''; echo '
'; if ( isset($_GET['link']) AND $_GET['link'] != '' ) echo ''; echo '
'; echo ''; echo ''; echo '
'; echo stripslashes($wppwt_description); echo '
'; } // end isset($_POST['tweet_link']) } elseif (isset($_REQUEST['oauth_verifier'])) { //getting access token from the retrieved code. $verifier = $_REQUEST['oauth_verifier']; $connection = gettwitteroauthconnection($_SESSION['request_token'], $_SESSION['request_token_secret']); $access_token = $connection->getAccessToken($verifier); $_SESSION['screen_name'] = $access_token["screen_name"]; $_SESSION['user_id'] = $access_token["user_id"]; $_SESSION['oauth_token'] = $access_token["oauth_token"]; $_SESSION['oauth_token_secret'] = $access_token["oauth_token_secret"]; // following script to refresh the page after session is set echo ''; } elseif (isset($_GET['redir']) AND 'twitter' == $_GET['redir']) { // change the callback url to your website url // $callback = "http://localhost/demos/tweet-it/"; $callback = (!empty($_SERVER['HTTPS'])) ? "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $connection = gettwitteroauthconnection(); $request_token = $connection->getRequestToken(esc_url($callback)); $_SESSION['request_token'] = $token = $request_token['oauth_token']; $_SESSION['request_token_secret'] = $request_token['oauth_token_secret']; switch ($connection->http_code) { case 200: /* Build authorize URL and redirect user to Twitter. */ $url = $connection->getAuthorizeURL($token); //header('Location: ' . $url); //Javascript redirection is used as the header is sent already. echo ''; break; default: /* Show notification if something went wrong. */ echo 'Could not connect to Twitter. Refresh the page or try again later.'; } } else { $callback = (!empty($_SERVER['HTTPS'])) ? "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $link = $callback . '&redir=twitter'; echo 'Connect to Twitter'; } ?>