I’m trying to write an application in PHP which can receive user authorization to post tweets automatically, and then send those tweets from the server side.
The application will actually be taking content from a user and posting it to several media sites at the same time, so requiring user interaction for the tweets is not an option.
I’ve tried going the the Twitter API documentation and, frankly, it’s worthless. The REST API documentation is all for OAuth, not OAuth2, so the URLs, signatures and encoding methods are all wrong. I tried using the “Abraham TwitterOAuth” library, but ot create the object, you have to already have an access token.
I tried this method, but don’t know what to do with the result:
$SendToken = CONSUMER_KEY . “:” . CONSUMER_SECRET;
$SendToken = base64_encode($SendToken);
$ch = curl_init(“https://api.twitter.com/oauth2/token”);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ’ . $SendToken,
$Data = “grant_type=client_credentials”;
curl_setopt($ch, CURLOPT_POSTFIELDS, $Data);
$Data = curl_exec($ch);
Can anyone help?