How can specify the profile to Tweeting

php
api

#1

We are developing an TYPO3 CMS extension that is in charge of managing the social network profiles. In this case Twitter. The API works with TYPO3 through Adapter Pattern.

Now, I have different Twitter profiles and I select in the view in which I want to publish (through a checkbox) and send a text that I want to publish in the chosen profiles.

The method to publish in Twitter is:

require $extensionPath . 'twitteroauth/autoload.php';
use Abraham\TwitterOAuth\TwitterOAuth;
...
public function doPublication($profile, \Vendor\MyExt\Domain\Model\Post $publication) {

 $status = $publication->getText();

 if(strlen($status)>=140) 
    $status = substr($status,0,139);

 $this->api = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret);
 $this->api->post('statuses/update', array('status' => "$status"));  

}

At this moment We are not using the profile name to publish, because We can not find a feature within the Twitter API to send a Post to a determined profile.

My question is if can define in some way the profile to which you want to publish. Because I have not found it yet.

In addition to this, the publication is always being made to a one profile of the list to choose, even if it is not selected. Always appears in the response json when executing statuses / update.


#2

The user access token ($access_token and $access_token_secret in your code) identifies which account is being used to access the Twitter API - that’s the account that the Tweet will be posted from.


#3

Thank you. I understand more about API. Excuse me, I have a checkbox list with the names of profiles that I want Tweeting, the olnly thing is select checkbox and the idea is by PHP do the next. Now, with $access_token and $access_token_secret I need to get them si I am using now $request_token = $this->api->oauth('oauth/request_token', array('oauth_callback' => OAUTH_CALLBACK)); and continue with statuses/update but I have a wrong answer

‘code’ => int 32
’message’ => string ‘Could not authenticate you.’

And, at the moment of $this->api->get("account/verify_credentials") I have a the same error.

Could you guide me for resolve this issue, please


#4

You have only implemented part of the OAuth flow. You are getting a request token. You also need to send the user to to twitter.com to authorize app access and then you exchange the request token for an access token.

You can read the docs here https://dev.twitter.com/web/sign-in/implementing
And you can also walk through the full flow using the TwitterOAuth demo site https://twitteroauth.com/redirect.php


#5

Thank you. I have implemented all flow, know works correctly. It ss importatnt this flow if you want to take access token without expire time. I had a other problem with callback but the problem was in the manage of TYPO3 system. Thank you again.