The important part is the action="twitter_post.php". This will tell the form which PHP file to send the tweet to, in order to run the PHP script and post the tweet on the server side.
Here is my sampleform.html file:
<!DOCTYPE HTML>
<html>
<body>
<form action="twitter_post.php" method="post">
The tweet to post on @deletrius Twitter account: <input type="text" name="tweetpost"><br>
<input type="submit">
</form>
</body>
</html>
As for the twitter_post.php file, this file will need to read the input text of the tweet to post, represented by name="tweetpost". Since we are sending this via POST, we can obtain the value by calling $_POST["tweetpost"] on the server side in our PHP script.
As for the oauth token and oauth secret, you will need to replace those with the ones from yourself, or with the information you received after the oauth authentication shown in my earlier post: http://leadingtechdonkey.blogspot.com/2016/05/2-how-to-integrate-twitter-into-app-in.html
Here is my twitter_post.php file that will take the tweet entered by the user and post it to Twitter:
<?php
require_once 'twitteroauth/autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
session_start();
$config = require_once 'config.php';
// connect with user token
$twitter = new TwitterOAuth(
$config['consumer_key'],
$config['consumer_secret'],
"REPLACE_WITH_YOUR_OWN_OAUTH_TOKEN",
"REPLACE_WITH_YOUR_OWN_OAUTH_SECRET"
);
$tweet = $_POST["tweetpost"];
// post a tweet
$status = $twitter->post(
"statuses/update", [
"status" => $tweet
]
);
echo ('Created new status with #' . $status->id . PHP_EOL);
print_r($status);
?>
Feel free to leave me a comment below for any clarifications or questions or comments.
[Last updated: 5/16/2016]