How to publish tweets?

Dec 9, 2013 at 3:51 PM
I have just started exploring the api. Can some kind soul tell me how to publish tweets from console to my twitter account?
Coordinator
Dec 10, 2013 at 11:16 AM
Hi,

Sorry for not responding earlier, I just did not see your message.
If you download the Source Code project you will find many examples on how to use Tweetinvi.

Now concerning your specific request. You can create a simple tweet by 2 different ways.
Use Tweet.Publish
ITweet t = new Tweet("Hello Tweetinvi!");
bool success =  t.Publish(token);
Console.WriteLine("Tweet has{0}been published", success ? " " : " not ");
Use TokenUser.PublishTweet
var tokenUser = new TokenUser(token);
tokenUser.PublishTweet("hello tweetinvi!");
Each of these examples use a Token which you need to create with your credentials.
IToken token = new Token("My Access token", "My Access token secret", "My Consumer key", "My Consumer secret");
Hope this helps.
Linvi
Marked as answer by linvi on 1/16/2014 at 4:15 AM
Dec 10, 2013 at 7:25 PM
Which files should I add as a rerence to use the tweetinvi api. I downloaded files in the link provided but when I am referencing it gives me an error that assembly referenced not correct.
Coordinator
Dec 10, 2013 at 7:30 PM
You should reference most of the projects.

If you have downloaded the Source Code. Ensure that you've added both TweetinCore and Tweetinvi in your references. It does not hurt to add the other references too. Otherwise take the Examplinvi project as a reference.

I you do not want to bother, just use Nuget and type the following command : Install-Package TweetinviAPI.

Linvi
Dec 10, 2013 at 7:45 PM
I installed them with nuget but I am not still able to use it by following statement in my code.

using Tweetinvi;


This is again saying missing assembly reference
Coordinator
Dec 10, 2013 at 7:48 PM
Here are all the namespaces you could need :
using oAuthConnection;
using Streaminvi;
using TweetinCore.Enum;
using TweetinCore.Events;
using TweetinCore.Interfaces;
using TweetinCore.Interfaces.oAuth;
using TweetinCore.Interfaces.StreamInvi;
using TweetinCore.Interfaces.TwitterToken;
using Tweetinvi;
using Tweetinvi.Model;
using TwitterToken;
using UILibrary;
Marked as answer by linvi on 1/16/2014 at 4:15 AM
Dec 10, 2013 at 7:51 PM
Edited Dec 10, 2013 at 7:52 PM
Sent you an email
Dec 10, 2013 at 7:51 PM
I have just sent you image of all things that I get on my screen via email
Dec 10, 2013 at 8:08 PM
Sorry for troubling but I re started VS 2010 and library works fine. As instructed in tweetinvi do I need to make changes in my app config file for using token?
Coordinator
Dec 10, 2013 at 8:10 PM
No you don't. You can simply have 4 const string parameters and use them :)
Feb 6, 2014 at 3:49 PM
Hi, I have tried both of the post methods above, and I am getting an unauthorised message, basically, I have a stream connected to my twitter account, and based on certain key words in tweets, I respond to the tweet with a thankyou message, so I have done the following
Tweet tw = new Tweet(e.Value.Creator.ScreenName + " Thanks for selecting : " + selection);
bool tmp = tw.Publish(token);

var tokenUser = new TokenUser(token);
tokenUser.PublishTweet("@" + e.Value.Creator.ScreenName + " Thanks for selecting : " + selection); 
I have even tried to just post a simple tweet, but I am getting the following message :

{"The remote server returned an error: (401) Unauthorized."}

am I missing something really silly ?? I know the token is ok, as I receive the messages no problem.

any pointers would be much appreciated.

Thanks
Feb 6, 2014 at 4:20 PM
its ok, I have just checked and I didn't have the right permissions on my application settings..

but, I have my colleague sending some test tweets, and I am sending a response back to him by creating a message with "@" + e.value.creator.screenname and then my message, it posts on my timeline but he doesn't seem to receive it, but saying that, he doesn't receive anything if I do it through twitter ????
Coordinator
Feb 6, 2014 at 4:34 PM
Hi,

This is working perfectly fine for me. The target user needs to be following you.
Also note that there can be a small delay before the target user can see it.
He also might need to refresh the page.

Linvi