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 1098251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:33:08+00:00 2026-05-17T00:33:08+00:00

This is the PHP code im using in conjunction with jQuery .ajax to create

  • 0

This is the PHP code im using in conjunction with jQuery .ajax to create a new Tweets:

/* Create a TwitterOauth object with consumer/user tokens. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);

    $qtweet = $_POST['tweet'];
    $connection->post('statuses/update', array('status' => $qtweet));

Data is supplied by form and a bit of jQuery .ajax:

<form id="tweethis" method='post' action=''>
    <textarea style="width: 42em;" name="tweet" rows="5" id="tweet" ></textarea>
    <br />
    <p class="confirm" style="padding-bottom: 4px;">Tweet Sent.</p>
    <span id="charLeft">140</span>  Characters left
    <br />
    <input type='submit' value='Tweet This!' name='submit' id='submit' />
</form>

$("#tweethis #submit").click(function() {  
    //The Tweet
    var tweettxt = $("textarea#tweet").val();
    var ptweettxt = 'tweet=' + tweettxt;
    $.ajax({
      type: "POST",
      url: "tweet.php",
      data: ptweettxt,
      success: function() {
        $('#tweethis .confirm').css('color','red').slideDown(500).delay(3000).slideUp(500);
        $('textarea#tweet').val("");
      }
    });
    return false;
}); 

I’d like to adapt the form to also deal with replies, so the user can click the ID of a tweet, that ID gets added to the FORM. The FORM will need another hidden field which will be initially blank so when the user submits without a reply ID they just send a Tweet.

However I’ll need some code in the PHP file to check if the _POST is empty or null, if null just send a tweet but if it has an ID create a reply.

How can I do the check if the field is empty or filled with an ID?

I also need help creating the reply.

The documentation is here: http://dev.twitter.com/doc/post/statuses/update

This is what I have written so far for the PHP:

$qtweet = $_POST['tweet'];
$tweetid = $_POST['tweetid'];
$connection->post('statuses/update', array('status' => $qtweet, 'in_reply_to_status_id => $tweetid'));

Not sure if I’m contructing the array correctly or this is acceptable to the Twitter API.

The .ajax will be trivial compared to all this as i’ll just pass the hidden form value as another value in the _POST.

Any help with this greatly appreciated, this is the last thing left for me to complete my first PHP project, I’ve created my own Twitter Client specifically designed for use at conferences where a hashtag is used to track the back channel.

  • 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-17T00:33:08+00:00Added an answer on May 17, 2026 at 12:33 am

    you use empty() to check if something is empty =)

    also you need to correct this line…

    $connection->post('statuses/update', array('status' => $qtweet, 'in_reply_to_status_id' => $tweetid));
    

    Don’t put the variable in quotes

    Maybe something like

    if ( empty( $_POST['tweetid'] ) ) {
        $connection->post('statuses/update', array('status' => $qtweet));
    }
    else {
        $connection->post('statuses/update', array('status' => $qtweet, 'in_reply_to_status_id' => $_POST['tweetid']));
    }
    

    You just have to put the id of tweet in the form

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this php code: try{ $dbh = new PDO(mysql:host=$host;dbname=$dbname,$user,$pass); $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); //
im using this php code to concat two querys: $qry = Create Table $this->tablename
I am using this php code to allow the user to send dojo.enchancedgrid to
I am using this PHP code: if (isset($_GET['c'])) { $pages = array(home, upload, signup);
I start a download using PHP with this code: <? $_REQUEST['file'] = urldecode($_GET['file']); header(Content-type:
I am using the following code to generate excel from sql through php.this is
This is the code I'm using: <?php // Set the MySQL Configuration $db_host =
I am using this code to send mail with php http://www.siteduzero.com/tutoriel-3-35146-e-mail-envoyer-un-e-mail-en-php.html#ss_part_4 . This code
So I'm using this code: <iframe src=http://www.connect.facebook.com/widgets/fan.php?href=http://www.facebook.com/pages/TopDesenecom/148037301911330&width=205&height=256&show_faces=true&stream=false&header=false&css=http://topdesene.com/template/fb.css></iframe> and facebook shows this code: <link href=http://external.ak.fbcdn.net/fbml_static_get.php?src=http%3A%2F%2Ftopdesene.com%2Ftemplate%2Ffb.css&appid=148037301911330&pv=1&sig=59bf9a037df3a88cb6ff142f25227177&filetype=css&cb=2
implementing publishActivity in PHP using the REST API using this code: $activity = array(

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.