Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:52:15+00:00 2026-05-23T21:52:15+00:00

I am trying to figure out how to let my users post a tweet

  • 0

I am trying to figure out how to let my users post a tweet by following a link on my site. This is the process I design:

  1. A link somewhere on my site will have an offer: “Send a Twit and receive a coupon”.
  2. Once they click on the offer link, they are redirected to Twitter for authorization.
  3. After they grant a permission to connect with their Twitter profile, I would like to send a post using Twitter API, with a pre-populated message, something like: “Trying out this online tool for free: http”//mylink.com”. After the message is posted they need to be redirected back to my site to a page with a coupon code.

I got about 75% done so far.

  1. I installed twitterOauth library
  2. Based on demo examples I can now do the following:
    — Link to Twitter (DEMO)
    — Login the user with Twitter
    — Redirect back to my site

What I still need to figure out is how to post the Tweet… Ideally I would like to show the message that will be posted, but without a functionality to edit it, just to let them know. I can possibly show it on the first page, which means I’d like to post it automatically once they grant permission to Twitter, right before redirecting to the coupon code. Where do I add POST functionality?

Here’s the return.php code.

<?php
/* Start session and load library. */
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');

// This is where we end up when the user comes back from twitter.
// First, we creat a new connection object
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
// Then we use it to send a twitter message

$connection->post('statuses/update', array('status' => 'Test message'));

// Finally, we redirect the user to the coupon page
header('Location: /privacy'); // Supplies user with coupon
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:52:16+00:00Added an answer on May 23, 2026 at 9:52 pm

    When Twitter redirects the user back to your site, send the Tweet then load the page with the coupon code. Although make sure the you’ve informed the user that their status will be updated if they authorize your app.

    You forgot exchanging for the access_tokens:

    <?php
    /* Start session and load library. */
    session_start();
    require_once('twitteroauth/twitteroauth.php');
    require_once('config.php');
    
    // This is where we end up when the user comes back from twitter.
    // First, we creat a new connection object
    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    
    $token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']);
    $_SESSION['oauth_token'] = $token_credentials['oauth_token']
    $_SESSION['oauth_token_secret'] = $token_credentials['oauth_token_secret'];
    
    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    
    // Then we use it to send a twitter message
    
    $connection->post('statuses/update', array('status' => 'Test message'));
    
    // Finally, we redirect the user to the coupon page
    header('Location: /privacy'); // Supplies user with coupon
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out whether the users I get from ads will buy
I'm trying to figure out why this doesn't work. Let's say you three models,
Trying to figure out how I can do this properly. The print_r looks like
trying to figure out why this is happening - I have an input text
Trying to figure out the best way to set up collection lists for users
Im trying to figure out how to let a user enter a website or
Pretty new to dependency injection and I'm trying to figure out if this is
I am trying to figure out the correct trig. eq./function to determine the following:
I'm trying to figure out the best way to design a rails model. For
I am just trying to figure out how to work this out. So, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.