Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all 4126 articles
Browse latest View live

New Post: Json data

$
0
0
Hi there,

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

Created Unassigned: Add support for user email. [2654]

$
0
0
It is now possible to get user email from twitter API. This however requires this URL query parameter to be added to the URL: "include_email=true".

Please push a fix that adds support for this.

P.S. If the following where added to the project, I would have been able to do this myself:

1. Mark the 'Resources' code file as public, instead of internal. This way, I can modify the query URLs.
2. Make available the raw json string received from the api in a property on each model. This way I would have been able to look up the extra fields not available on the concrete c# object.

New Post: I want to store users authentication to use them an new threads, your help is needed

$
0
0
Dear Linvi,

good day bro,

Would you please help in this , I'm trying to create a new thread with different user credentials ( Verifier Code , authorizationId) but it didn't work , also i tried use them with (consumerKey and consumerSecret ) no luck too , I've read that there are ( Access_token, access_token_secret) ,but I don't know how to get it from user to store it to use later in new threads.

I really appreciate your help

Best wishes and regards.

Created Unassigned: Why is IUserMentionEntity.Id nullable? [2655]

New Post: I can't get GetAuthorizationURL to work outside of Page Load

$
0
0
Note: This is version 0.9.9.8

The GetAuthorizationURL code works when I place everything in the page load but when I break it in half so I can activate it using a button it does not work. The second half of the code (which is after the redirect from twitter authorize page) gets all the information it needs and is in the page load.

This is when it is properly working and everything is in Page Load()
    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

New Post: Saving Tweet to disk

$
0
0
Hi!

I'm trying to save Tweets that I recieved from the MatchingTweetReceived event to disk, but serializing TweetDTOs results in NotImplementedExceptions and a lot of NULL values in the resulting JSON string (id, createdAt, user,...). Is there a proper way to dump recieved tweets to disk?

Thanks a lot for your help.

New Post: FilteredStream MatchingFollow

$
0
0
Hi Linvi,

There is no MatchingFollows similar to MatchingTracks for FilteredStream?

matchingTrack.ElementAt(0) returns null while trying to follow 2 accounts and adding no track.

stream.AddFollow(account1);

stream.AddFollow(account2);

stream.MatchingTweetReceived += (sender, args) =>
            {
                var matchingTrack = args.MatchingTracks;

var track = matchingTrack.ElementAt(0);

Thx

New Post: Using next_cursor on Campaigns

$
0
0
Hi,

I am calling the below twitter Ads API to get all campaigns in my ads account:
https://ads-api.twitter.com/0/accounts/Acount_id/campaigns/

I am using TwitterAccessor.ExecuteJsonGETQuery to make the call.
(I can change it to TwitterAccessor.ExecuteGETQuery<MyDTO>)

It returns json as shown below (end of post)

It returns 200 / 4500 results and also a next_Cursor field in the end.
How do I use the next_cursor to get all the results.
I went through https://github.com/linvi/tweetinvi/wiki/Custom-Queries#cursor-query
but wasn't able to understand clearly.

Sample Json:
{
"request": { "params": { "account_id": "XXXXXXXXXXX" } },
"data": [
{
  "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
}
.
.
.
],
"data_type": "XXXXXXXXXXX",
"total_count": XXXXXXXXXXX,
"next_cursor": "ABCD1"
}

New Post: GetUserFromID Rate Limit application / consumer wide?

$
0
0
Hi linvi,

I use the following in my background worker task:
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).

Immediately when one of theses task runs into the Rate Limit all other tasks of this kind go into idle mode and wait the Rate Limit to be resetted.

New Post: GetUserFromID Rate Limit application / consumer wide?

$
0
0
Opened Question at Github, created it accidently here.

New Post: Streams - portable httpwebrequest - proxy

$
0
0
As the project targets the portable libraries - why oh why, the cause of all my suffering lol - and connect via the httpwebrequest, there is no proxy / iwebproxy property to set (that I can see)

Is there anyway to connect via a proxy?


I have tried searching around and there doesn't seem to be a lot of information on this. Only thing I can think of is rebuliding tweetinvi targeting .net4.5 only, but as I cannot just remove the portable targetings, I have to recreate the whole solution adding each file by file - not a pleasant way to spend the afternoon so am hoping beyond hope there is a better way to do this


cheers

Created Unassigned: Current thread settings being dropped [2659]

$
0
0
```
Tweetinvi.TweetinviConfig.CURRENT_WEB_REQUEST_TIMEOUT = 60000;
Tweetinvi.TweetinviConfig.CURRENT_PROXY_URL = "127.0.0.1....";

var settings = new Tweetinvi.Core.TweetinviSettingsAccessor();
// confirmed is correct settings.CurrentThreadSettings.ProxyURL
```

This is all set, stepped through, is all working correctly.


Actions are run using:

```
TwitterCredentials.ExecuteOperationWithCredentials(cred, () =>
{
....
}

```

yet, when responding to a stream notification, the settings information is dropped!

After making a call to the API

This code runs:
class: HttpClientWebHelper
Method: public HttpResponseMessage GetResponseMessageFromWebRequest(WebRequest webRequest)

```
var requestTask = TaskEx.Run(() => GetResponseMessageFromWebRequestAsync(webRequest, _tweetinviSettingsAccessor.WebRequestTimeout));
```

Just before stepping in, the
```
tweetinviSettingsAccessor
```
is correct, my settings are in, but when I step in, the settings are null and are override

after the callback runs, I am back in the code, my current settings are there, then this line runs

```
var resultingTask = TaskEx.WhenAny(requestTask, TaskEx.Delay(_tweetinviSettingsAccessor.WebRequestTimeout)).Result;
```

again, just before, currentthreadsettigns correct, callback executes, settings gone - overidden




So from what I can tell, the async, callback nature of it all, is running things in different "threads" or whatever the terminology and ignoring how other parts of the program function, by having to assign the details to the executing thread, which will detect it later when required and use the parameters.



Any definite ideas on what is going on here? tbh I am a bit lost in it all - and probably is me not understanding things and doing it wrong. The whole paradigm of assigning variables to the executing thread is very different to how I normally do things (assign properties to the object and pass that to execute it), so I am probably trying to do things with the wrong mindset :-s

New Post: Streams - portable httpwebrequest - proxy

$
0
0
so I got it working

I took the StreamTask out the portable project, and added a new project just for this class. Then some hacks to allow the container to know what IStreamTask implementation is, then am able to set the proxy.

Commented Unassigned: Current thread settings being dropped [2659]

$
0
0
```
Tweetinvi.TweetinviConfig.CURRENT_WEB_REQUEST_TIMEOUT = 60000;
Tweetinvi.TweetinviConfig.CURRENT_PROXY_URL = "127.0.0.1....";

var settings = new Tweetinvi.Core.TweetinviSettingsAccessor();
// confirmed is correct settings.CurrentThreadSettings.ProxyURL
```

This is all set, stepped through, is all working correctly.


Actions are run using:

```
TwitterCredentials.ExecuteOperationWithCredentials(cred, () =>
{
....
}

```

yet, when responding to a stream notification, the settings information is dropped!

After making a call to the API

This code runs:
class: HttpClientWebHelper
Method: public HttpResponseMessage GetResponseMessageFromWebRequest(WebRequest webRequest)

```
var requestTask = TaskEx.Run(() => GetResponseMessageFromWebRequestAsync(webRequest, _tweetinviSettingsAccessor.WebRequestTimeout));
```

Just before stepping in, the
```
tweetinviSettingsAccessor
```
is correct, my settings are in, but when I step in, the settings are null and are override

after the callback runs, I am back in the code, my current settings are there, then this line runs

```
var resultingTask = TaskEx.WhenAny(requestTask, TaskEx.Delay(_tweetinviSettingsAccessor.WebRequestTimeout)).Result;
```

again, just before, currentthreadsettigns correct, callback executes, settings gone - overidden




So from what I can tell, the async, callback nature of it all, is running things in different "threads" or whatever the terminology and ignoring how other parts of the program function, by having to assign the details to the executing thread, which will detect it later when required and use the parameters.



Any definite ideas on what is going on here? tbh I am a bit lost in it all - and probably is me not understanding things and doing it wrong. The whole paradigm of assigning variables to the executing thread is very different to how I normally do things (assign properties to the object and pass that to execute it), so I am probably trying to do things with the wrong mindset :-s
Comments: ** Comment from web user: user_martin **

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!


Commented Unassigned: Current thread settings being dropped [2659]

$
0
0
```
Tweetinvi.TweetinviConfig.CURRENT_WEB_REQUEST_TIMEOUT = 60000;
Tweetinvi.TweetinviConfig.CURRENT_PROXY_URL = "127.0.0.1....";

var settings = new Tweetinvi.Core.TweetinviSettingsAccessor();
// confirmed is correct settings.CurrentThreadSettings.ProxyURL
```

This is all set, stepped through, is all working correctly.


Actions are run using:

```
TwitterCredentials.ExecuteOperationWithCredentials(cred, () =>
{
....
}

```

yet, when responding to a stream notification, the settings information is dropped!

After making a call to the API

This code runs:
class: HttpClientWebHelper
Method: public HttpResponseMessage GetResponseMessageFromWebRequest(WebRequest webRequest)

```
var requestTask = TaskEx.Run(() => GetResponseMessageFromWebRequestAsync(webRequest, _tweetinviSettingsAccessor.WebRequestTimeout));
```

Just before stepping in, the
```
tweetinviSettingsAccessor
```
is correct, my settings are in, but when I step in, the settings are null and are override

after the callback runs, I am back in the code, my current settings are there, then this line runs

```
var resultingTask = TaskEx.WhenAny(requestTask, TaskEx.Delay(_tweetinviSettingsAccessor.WebRequestTimeout)).Result;
```

again, just before, currentthreadsettigns correct, callback executes, settings gone - overidden




So from what I can tell, the async, callback nature of it all, is running things in different "threads" or whatever the terminology and ignoring how other parts of the program function, by having to assign the details to the executing thread, which will detect it later when required and use the parameters.



Any definite ideas on what is going on here? tbh I am a bit lost in it all - and probably is me not understanding things and doing it wrong. The whole paradigm of assigning variables to the executing thread is very different to how I normally do things (assign properties to the object and pass that to execute it), so I am probably trying to do things with the wrong mindset :-s
Comments: ** Comment from web user: user_martin **

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 :-)



Commented Unassigned: Current thread settings being dropped [2659]

$
0
0
```
Tweetinvi.TweetinviConfig.CURRENT_WEB_REQUEST_TIMEOUT = 60000;
Tweetinvi.TweetinviConfig.CURRENT_PROXY_URL = "127.0.0.1....";

var settings = new Tweetinvi.Core.TweetinviSettingsAccessor();
// confirmed is correct settings.CurrentThreadSettings.ProxyURL
```

This is all set, stepped through, is all working correctly.


Actions are run using:

```
TwitterCredentials.ExecuteOperationWithCredentials(cred, () =>
{
....
}

```

yet, when responding to a stream notification, the settings information is dropped!

After making a call to the API

This code runs:
class: HttpClientWebHelper
Method: public HttpResponseMessage GetResponseMessageFromWebRequest(WebRequest webRequest)

```
var requestTask = TaskEx.Run(() => GetResponseMessageFromWebRequestAsync(webRequest, _tweetinviSettingsAccessor.WebRequestTimeout));
```

Just before stepping in, the
```
tweetinviSettingsAccessor
```
is correct, my settings are in, but when I step in, the settings are null and are override

after the callback runs, I am back in the code, my current settings are there, then this line runs

```
var resultingTask = TaskEx.WhenAny(requestTask, TaskEx.Delay(_tweetinviSettingsAccessor.WebRequestTimeout)).Result;
```

again, just before, currentthreadsettigns correct, callback executes, settings gone - overidden




So from what I can tell, the async, callback nature of it all, is running things in different "threads" or whatever the terminology and ignoring how other parts of the program function, by having to assign the details to the executing thread, which will detect it later when required and use the parameters.



Any definite ideas on what is going on here? tbh I am a bit lost in it all - and probably is me not understanding things and doing it wrong. The whole paradigm of assigning variables to the executing thread is very different to how I normally do things (assign properties to the object and pass that to execute it), so I am probably trying to do things with the wrong mindset :-s
Comments: ** Comment from web user: linvi **

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

New Post: Streams - portable httpwebrequest - proxy

$
0
0
Looking at the code proxies should be quite easy to implement without having to get rid of the proxy classes.
By simply changing the StreamTask class (line 89 - after _twitterQuery = _generateTwitterQuery();) and set up the TwitterQuery proxy this should be enabled for the stream.

This has not been done in regard to testing time required but this should be as easy as that.

New Post: GetFollowers() returning 0 followers

$
0
0
Hi,

I have a list of Twitter users and I want to get just 20 followers of each of these users in my list.

I execute User.GetFollowers(20) in a loop. I sometimes do get followers but sometimes get 0 followers. I checked the actual user on Twitter and the user has lots of followers (~ 1500).

I am handling rate limit.
I have a Thread.Sleep(queryRateLimits.ResetDateTimeInMilliseconds) in TweetinviEvents_QueryBeforeExecute event.

Can you please suggest some workarounds or point any mistake in my approach,.

Thanks.

Created Unassigned: User stream doesnt work but i get no error. [2662]

$
0
0
I have used the code below to create a user stream and recieve direct messages. It works in my sample project fine, but when i try to implement it in my existing project, after the stream starts it doesnt trigger the events when it starts or direct message. With brake points in the events it clearly doesnt trigger.

Tweetinvi.Core.Credentials.TwitterCredentials creds = new Tweetinvi.Core.Credentials.TwitterCredentials(consumerKey, consumerSecret, accessToken, accessTokenSecret);

```
Auth.SetUserCredentials(consumerKey, consumerSecret, accessToken, accessTokenSecret);

var stream = Tweetinvi.Auth.ExecuteOperationWithCredentials(creds, () =>
{
return Tweetinvi.Stream.CreateUserStream(creds);
});

stream.StreamStarted += (sender, args) =>
{
Trace.WriteLine("Stream Started");
};

stream.MessageReceived += (s, a) =>
{
Trace.WriteLine("You received the message : {0}", a.Message.Text);
};

stream.StartStream();
```

Has anyone had this before? Any ideas? How can i better debug this?

Regards
Carl

New Post: TweetInvi 0.9.3.3 to 0.9.10 credentials and other...

$
0
0
Hi everybody,
I meet some issue since few days with my twitter app using an old tweetinvi version (0.9.3.3).
my app with this tweetinvi version worked like a charm since yesterday.
Did Twitter made some changes on OAuth ?
With TweetInvi 0.9.3.3, i've no error in the code (see below), but the qTweets is empty !?
So, i upgrade to 0.9.10 and my VB code not match with the new TweetInvi version.
errors on TwitterCredentials, Search.GenerateSearchTweetParameter, Core.Interfaces.Models.Parameters...
Following my code :
 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 ?

Thanks.
Patrick
Viewing all 4126 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>