Yes this feature will be added in version 1.1 of Tweetinvi. It has recently been requested multiple times.
You can find the Work Item here.
Cheers,
Linvi
protected void Page_Load(object sender, EventArgs e)
{
if (Request["oauth_token"] == null)
{
var appCreds = new ConsumerCredentials("consumer_key",
"consumer_secret");
var redirectURL = Request.Url.AbsoluteUri;
var url = CredentialsCreator.GetAuthorizationURL(appCreds, redirectURL);
Response.Redirect(url);
}
else
{
var verifierCode = Request.Params.Get("oauth_verifier");
var authorizationId = Request.Params.Get("authorization_id");
//Create the user credentials
var userCreds = CredentialsCreator.GetCredentialsFromVerifierCode(verifierCode, authorizationId);
Auth.ExecuteOperationWithCredentials(userCreds, () =>
{
Tweet.PublishTweet("Test Tweet 1");
});
}
}
Now when I break it into two for some odd reason it does not work. Here is the 1st portion which is in the button protected void Button1(object sender, EventArgs e)
{
if (Request["oauth_token"] == null)
{
var appCreds = new ConsumerCredentials("consumer_key", "consumer_secret");
var redirectURL = Request.Url.AbsoluteUri;
var url = CredentialsCreator.GetAuthorizationURL(appCreds, redirectURL);
Response.Redirect(url);
}
}
Now here is the second part after the authorization/redirect protected void Page_Load(object sender, EventArgs e)
{
if (Request["oauth_verifier"] != null)
{
var verifierCode = Request.Params.Get("oauth_verifier");
var authorizationId = Request.Params.Get("authorization_id");
//Create the user credentials
var userCreds = CredentialsCreator.GetCredentialsFromVerifierCode(verifierCode, authorizationId);
Auth.ExecuteOperationWithCredentials(userCreds, () =>
{
Tweet.PublishTweet("Test Tweet 2");
});
}
}
I still get the verifierCode and authorizationId as normal. No error occurs it should have posted a new tweet. Everything is filled in properly. It looks like nothing is wrong. Please help as this is really odd {
var matchingTrack = args.MatchingTracks;
{
"name": "XXXXXXXXXXX",
"start_time": "XXXXXXXXXXX",
"reasons_not_servable": [ "XXXXXXXXXXX", "XXXXXXXXXXX" ],
"servable": false,
"daily_budget_amount_local_micro": XXXXXXXXXXX,
"end_time": "XXXXXXXXXXX",
"funding_instrument_id": "XXXXXXXXXXX",
"standard_delivery": true,
"total_budget_amount_local_micro": XXXXXXXXXXX,
"id": "XXXXXXXXXXX",
"paused": false,
"account_id": "XXXXXXXXXXX",
"currency": "XXXXXXXXXXX",
"created_at": "XXXXXXXXXXX",
"updated_at": "XXXXXXXXXXX",
"deleted": false
},
{
"name": "XXXXXXXXXXX",
"start_time": "XXXXXXXXXXX",
"reasons_not_servable": [ "XXXXXXXXXXX", "XXXXXXXXXXX" ],
"servable": false,
"daily_budget_amount_local_micro": XXXXXXXXXXX,
"end_time": "XXXXXXXXXXX",
"funding_instrument_id": "XXXXXXXXXXX",
"standard_delivery": true,
"total_budget_amount_local_micro": XXXXXXXXXXX,
"id": "XXXXXXXXXXX",
"paused": false,
"account_id": "XXXXXXXXXXX",
"currency": "XXXXXXXXXXX",
"created_at": "XXXXXXXXXXX",
"updated_at": "XXXXXXXXXXX",
"deleted": false
}
.
.
.
],private void accounttask_DoWork(object sender, DoWorkEventArgs e)
{
Auth.ExecuteOperationWithCredentials(creds, () =>
{
RateLimit.RateLimitTrackerOption = RateLimitTrackerOptions.TrackOnly;
TweetinviEvents.QueryBeforeExecute += (senderT, args) =>
{
...
}
});
ActualStep = 1;
GetFollowers();
ActualStep = 2;
GetFollowerDetails();
}
private void GetFollowerDetails()
{
Auth.ExecuteOperationWithCredentials(creds, () =>
{
for (int ix = 0; ix <= newFollowersID.Count - 1; ix++ )
{
long iUser = Convert.ToInt64(newFollowersID[ix]);
var user = User.GetUserFromId(iUser);
...
}
}
}
As I saw now, that even with different Twitter account credentials the Rate Limit of 181 for getting a user's details seems to be application wide (or consumer key wide).so the actual code that first seems to have lost my threadsettings is the
``
var requestTask = TaskEx.Run(() => GetResponseMessageFromWebRequestAsync(webRequest, _tweetinviSettingsAccessor.WebRequestTimeout));
```
more explicity the parameter
```_tweetinviSettingsAccessor.WebRequestTimeout```
this property is
```
public int WebRequestTimeout
{
get { return CurrentThreadSettings.WebRequestTimeout; }
set { CurrentThreadSettings.WebRequestTimeout = value; }
}
````
and the property CurrentThreadSettings seems to generate a new instance instead of detecting the existing!
urghh seems I got the layout wrong above
so anyway, have hacked a fix in.
The issue is caused by running the method:
```
public async Task<HttpResponseMessage> GetResponseMessageFromWebRequestAsync(WebRequest webRequest, int timeout, string sProxy)
```
from the TaskEx callback action thing. When that function runs, and any functions called from there, there could not access the currenthreadsettings, they didn't exist, so they were overwritten.
The fix was to just make sure that the calling method passes in all currenthreadsettings information that was wanted.
Not very clean / bit hacky, but is working and I can now finish for the day :-)
Hello there,
I think I would need more of your code to understand whether the issue is with Tweetinvi or if the issue is how you use Tweetinvi.
It would be useful if you could share more. But the way Tweetinvi is supposed to work is that any thread/task in from which you execute an operation will have its own configuration. If you want to use the same one in multiple threads you can simply copy the entire configuration or call an init function that will initialize the Tweetinvi config.
Please send more details regarding this issue.
Cheers,
Linvi
StreamTask
class (line 89 - after _twitterQuery = _generateTwitterQuery();
) and set up the TwitterQuery proxy this should be enabled for the stream. Public Sub oauth_credential()
TwitterCredentials.SetCredentials(token, token_secret, consumer_key, consumer_secret)
End Sub
Private Sub ProcessTweets_RequestLoad()
oauth_credential()
Dim SearchParams = Search.GenerateSearchTweetParameter(TwitterRschRequest)
If TwittorIsRunning Then
SearchParams.MaximumNumberOfResults = 50
Else
SearchParams.MaximumNumberOfResults = 120
TwittorIsRunning = True
End If
SearchParams.TweetSearchFilter = Core.Interfaces.Models.Parameters.TweetSearchFilter.All
'Dim FinaleRsch As List(Of clTweetsList) = Nothing
Try
Dim tweets = Search.SearchTweets(SearchParams)
' linq
Dim qTweets = From rsch In tweets Order By rsch.CreatedAt Descending _
Where rsch.IsRetweet = False _
Select New clTweetsList() With _
{
.Tw_Id = rsch.IdStr,
.Creator_Id = rsch.Creator.IdStr,
.Creator_SceenName = rsch.Creator.ScreenName,
.Creator_Image = rsch.Creator.ProfileImageUrl,
.Tw_Message = rsch.Text,
.Tw_CreateDate = rsch.CreatedAt
}
FinaleRsch = qTweets.ToList
Catch ex As Exception
MsgBox("error (ProcessTweets_RequestLoad = " & FinaleRsch.Count & ") : " & ex.Message)
Exit Sub
End Try
End Sub
Some ideas ?