I don't suppose anyone has used the latest version of TweetSharp to do a twitter status update, I was using the old version and now getting a bit lost with this OAuth stuff and cannot get it to work.
I'd just like some example code of using it to do a simple status update?
This URL will provide the example you need to get your head around OAuth: http://tweetsharp.codeplex.com/wikipage?title=UserGuide&referringTitle=Documentation
From there, there's a method on TwitterService called SendTweet which should be fairly straightforward. Once you have an access token, you can do it like this:
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
service.SendTweet("I'm totally tweeting!");
Related
Just trying to do some basic testing of the Twitter API.
I've generate my keys/secrets and a bearer token, and been able to do simple Get/Create/Updates fine using the TweetInvi package.
However, I'm just totally stuck at how to get the Filtered Stream working to monitor for at mentions?
I have something like this:
var userClient = new TwitterClient(consumerKey, consumerSecret, accessToken, accessTokenSecret);
var stream = userClient.Streams.CreateFilteredStream();
stream.AddTrack("#AccountToFilterBy");
stream.MatchingTweetReceived += (sender, eventReceived) =>
{
// do some stuff
};
await stream.StartMatchingAnyConditionAsync();
This just won't work for me, I get a 403 error each time. I've tried just passing the consumer key/secret, using the client id key/secret (as I don't really know what it's for) and also added in the Bearer token as well to see if that helps, but just keep getting 403 error each time.
Has anyone got this working, was there a breaking change for TweetInvi as I can't find much info on it?
I am getting the same error, but I do not believe it is related to TweetInvi lib. For example, using Postman Twitter API when you create a tweet, it works. But it gives me same 403 error for for sampled or filtered stream using Postman Twitter API. I think it has to do with twitter permissions.
I've been trying for days on this and think that the issue is somewhere with my developer account but thought I'd ask for advice here first before digging in there.
I have followed the documentation and multiple tutorials and this should work it seems but no matter what call I make using Tweetinvi to Twitter I get "Forbidden" which when looking at the twitter codes means my authorization is correct but that I am asking for something that I don't have access to, but I am just trying to send a test tweet to see if the program works, which according to Twitter's documentation I should have full access to. Here's the code that I took from Tweetinvi's Tutorial on how to make a "Hello World" tweet but it just doesn't work cuz it returns "Forbidden".
static async Task Main(string[] args)
{
var userClient = new TwitterClient("APIKey", "sAPIKey", "AccessToken", "sAccessToken");
var tweet = await userClient.Tweets.PublishTweetAsync("This is a test tweet");
Console.WriteLine(tweet);
}
It's not just the send tweet function either, if I try to pull any information at all it says it's forbidden so I feel the issue is on Twitter side not my code but I am just trying to learn it as a hobby and have no idea. Just was told Tweetinvi would make everything take 5 minutes and now I am at three days of trying to figure this out. Any help in figuring this out would be nice and greatly appreciated.
Twitter's latest API release [Nov 15th 2021] has an entry level of access called "Essential" that provides access to the v2 API, because this should be the base for most new apps. If you need access to v2 and also to the legacy v1.1 APIs in the same app, you will need "Elevated" access, which is also available for free. The PublishTweetAsync method you are calling in the code in this question is trying to hit the v1.1 Tweet statuses/update endpoint, so your app will need Elevated access in order to make it work.
I am currently trying to do a search from Twitter using C#.
I am new to C#, and after finding that I should use TweetSharp (https://stackoverflow.com/questions/27266419/twitter-api-1-1-with-net-3-5?noredirect=1&lq=1#=) and installing it with NuGet on VisualStudio, I struggle to make a simple authentification and search, as I did not find any simple example based solely on TweetSharp.
I already got my API key, API secret, access token and access token secret (on the Twitter dev website).
All I want is to get some JSON data after searching a hashtag.
Simple example code based on uniquely on TweetSharp (and no other libraries, especially ones not findable on NuGet) would save my life ! A documentation for TweetSharp might also do the trick, currently I did not find it...
Cheers,
Kevin
Following your first comment. Tweetinvi is a library that has been actively maintained for 4 years now as compared to Tweetsharp. It has been available on nuget since 2013 and has recently published its first major version 1.0.
To answer your question using Tweetinvi:
// Authentication
Auth.SetUserCredentials("CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");
// Get json directly
var tweetsJson = SearchJson.SearchTweets("hello");
// Get json from ITweet objects
var tweets = Search.SearchTweets("hello");
// JSON Convert from Newtonsoft available with Tweetinvi
var json = JsonConvert.SerializeObject(tweets.Select(x => x.TweetDTO));
var tweetDTOsFromJson = JsonConvert.DeserializeObject<ITweetDTO[]>(json, JsonPropertiesConverterRepository.Converters);
var tweetsFromJson = Tweet.GenerateTweetsFromDTO(tweetDTOsFromJson);
I'm attempting to get a list of all Recurring Payment plans using the C# API. The result is always NULL. What am I doing wrong? I setup and tested other similar API requests such as Invoie.GetAll and that works, so I am confident my user account is setup correctly, I have a good auth token, etc.
Here is my code (note: I've tried passing the optional parameters too with no luck). Perhaps there is a bug with the Api?
var plans = PayPal.Api.Plan.List(_apiContext);
return Xml(plans);
Turns out I needed to use Express Checkout of the NVP and SOAP API Reference. I have something working now.
I am new to developing with the Goolge API’s. I am trying to get the Google.Apis.Freebase.V1 API working in C#. Does anyone have a small example on using this API in C#? I have spent the last several days looking and can only find a couple of examples for the old Freebase Api. Nothing for the Google API.
I am just looking for a simple example on setting up a connection to the API, doing a search, then how to handle a MQL query back into a Json object. The simpler the better.
Thanks
Scott
The correct code to do a MQL query in C# using the Google API Client Library should look something like this:
string API_KEY = "your-api-key-here";
FreebaseService service = new FreebaseService{ Key = API_KEY };
String query = "[{\"id\":null,\"name\":null,\"type\":\"/astronomy/planet\"}]";
FreebaseService.MqlreadRequest request = service.Mqlread(query);
string response = request.Fetch();
Console.WriteLine (response);
Unfortunately, there seems to be some sort of error with the client library right now as its not returning any results. I'll try to figure out what's going on there.
Update: The problem appears to be that the client library passes along an alt=json parameter which the Freebase API is unable to support. The Python client library has a way to disable this but there no way to do it in .Net. You can follow the open bug for this on the Google Code project.