Publish Tweets from cBot

Created at 12 Nov 2013, 21:55
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Hyperloop's avatar

Hyperloop

Joined 23.10.2013

Publish Tweets from cBot
12 Nov 2013, 21:55


I'm using the Twitterinvi .NET library to attempt to publish Tweets from my script. When I run this test code, nothing is happening. If anyone has any experience with this, some help would be appreciated.

//#reference: C:\Users\Hyperloop\Documents\cAlgo\Sources\References\TwitterToken.dll
//#reference: C:\Users\Hyperloop\Documents\cAlgo\Sources\References\oAuthConnection.dll
//#reference: C:\Users\Hyperloop\Documents\cAlgo\Sources\References\Tweetinvi.dll
//#reference: C:\Users\Hyperloop\Documents\cAlgo\Sources\References\TweetinCore.dll
// -------------------------------------------------------------------------------
//
//    TestTweet.cs
//
// -------------------------------------------------------------------------------

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
using oAuthConnection;
using TweetinCore.Interfaces;
using TweetinCore.Interfaces.TwitterToken;
using Tweetinvi;
using TwitterToken;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC)]
    public class TestTweet : Robot
    {
        protected override void OnStart()
        {
            string AccessToken = "1234567890";
            string AccessTokenSecret = "0987654321";
            string ConsumerKey = "abcdefg";
            string ConsumerSecret = "ABCDEFG";

            IToken token = new Token(AccessToken, AccessTokenSecret, ConsumerKey, ConsumerSecret);

            PublishTweet(token, "Test Tweet");

            Stop();
        }

        public static void PublishTweet(IToken argToken, string argTweet)
        {
            ITweet t = new Tweet(argTweet);
        }
    }
}

 


@Hyperloop
Replies

Hyperloop
12 Nov 2013, 22:12

No idea why this works, but I simply placed the line below in PublishTweet and it ran with no problems.

Console.WriteLine("Tweet has{0}been published", t.Publish(argToken) ? " " : " not ");

 

public static void PublishTweet(IToken argToken, string argTweet)
        {
            ITweet t = new Tweet(argTweet);
            Console.WriteLine("Tweet has{0}been published", t.Publish(argToken) ? " " : " not ");
        }

 


@Hyperloop