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
My twitter_post.php file:
<?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_AUTHENTICATED_USER_OAUTH_TOKEN",
"REPLACE_WITH_AUTHETICATED_USER_OAUTH_TOKEN_SECRET"
);
// post a tweet
$status = $twitter->post(
"statuses/update", [
"status" => "@deletrius I posted using Twitter REST API! http://leadingtechdonkey.blogspot.com/"
]
);
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/10/2016]
No comments:
Post a Comment