I am relatively new to programming in C# (Learning on my own for a school project) and decided to try using TweetInvi to implement Twitter functionality.
So far it's going good, got the authentication and publishing up and running, but I'm struggling to find out how to use the DestroyTweet() method.
It, and many other methods takes a tweetID parameter, which I can't figure out of how to find for a specific tweet.
Using the following code to publish a tweet, how can i find the tweetID of this tweet?
public ITweet publishTweet(string text)
{
return Tweet.PublishTweet(text);
}
// Snippet from a test method in main class.
twitter.twitterUser.publishTweet(System.Console.ReadLine());
// Still working on GUI so using ReadLine for now.
It's probably an easy solution, but I just can't figure it out!
Thanks in advance.
You can try something like this:
public string PublishTweet(string text)
{
var appCredentials = new TwitterCredentials(_apiKey,_apiSecret, _accessToken, _accessTokenSecret);
Tweetinvi.Auth.SetCredentials(appCredentials);
text = "my tweet";
var publishedTweet = Tweetinvi.Tweet.PublishTweet(text);
var tweetId = publishedTweet.Id.ToString();
return tweetId;
}
You just need to get the published tweet into a var for the result of the PublishTweet() method then you select the field(s) you need.
Simple solution. As explained before you need to take the tweet back from PublishTweet.
string text = "text";
ITweet tweet = Tweet.PublishTweet(text);
bool destroySuccess = tweet.Destroy();
Related
I am attempting to create the backend of a Twitch Extension that will search for all other users streaming the same game. The only way to get the Category with which to compare games is if the channel in question is live. This is fine, as the extension should will only be working whenever the stream goes live.
My issue is that I do not know how I can determine whether or not the user of the extension has gone online.
public static async Task<string> GetStreamAsync()
{
string product = "";
List<Stream> finalProduct = new List<Stream>();
var response = await _httpClient.GetAsync("https://api.twitch.tv/helix/streams?user_login=Ninja");
if (response.IsSuccessStatusCode)
{
product = await response.Content.ReadAsStringAsync();
var streamToRelate = JsonConvert.DeserializeObject<RootStream>(product);
finalProduct = await GetAllRelatedChannels(streamToRelate.Data.FirstOrDefault());
}
return product;
}
As you can see, I've hard coded a stream that I knew was online at the time (Ninja). This data was returned perfectly fine, but the next step is to pass a string into this function with which to search. How could I go about getting the "User" of the extension at runtime? If I am completely off-base, and am missing certain concepts, please let me know as well and I will do further research if necessary.
what is the best way to get daily bytes-out and byte-in report for every user in hotspot list(without the user manager).i found the tik4net but i couldn't use it and i found almost no documentation on this reference.
i have tried the mk.cs and tik4net already but no luck so far.
this was the sample on using torch tool :
using (ITikConnection connection = ConnectionFactory.CreateConnection(TikConnectionType.Api))
{
connection.Open("IP", "USR", "PW");
var loadingContext = connection.LoadAsync<ToolTorch>(
torchItem => Console.WriteLine(torchItem.ToString()),
error => Console.WriteLine(error.ToString()),
connection.CreateParameter("interface", "DSL"),
connection.CreateParameter("port", "any"),
connection.CreateParameter("src-address", "0.0.0.0/0"),
connection.CreateParameter("dst-address", "0.0.0.0/0"));
Console.ReadLine();
loadingContext.Cancel();
{
so the question is:
what is the best reference in c# to get user reports without the user manager in c#?
can anyone please provide some sample code ?
UPDATE :
i just worked around and played with the code a little bit and got here :
using (ITikConnection connection = ConnectionFactory.CreateConnection(TikConnectionType.Api))
{
connection.Open("IP", "USR", "PW");
var hs = connection.LoadAll<HotspotActive>();
foreach (var user in hs)
{
var ids = user.Id;
listBox1.Items.Add(ids);
connection.Delete<HotspotActive>(user);
}
}
but i get an exception error on connection.Delete<HotspotActive>(user); , i dont know if i went the correct way.
Good day everyone. I am pretty new to Mobile Development using C# and XAMARIN. My problem is I am trying to get the current user's first name from Parse.com database and display it on a textview, but I am getting nothing. Here's my code for getting the user data:
public async void getData(){
var ProfileName = await ParseObject.GetQuery ("User")
.WhereEqualTo ("FirstName", ParseUser.CurrentUser).FindAsync ();
string ProfName = ProfileName.ToString ();
name.Text = ProfName; //name.Text is the text view
}
Thank you everyone.
it's me again. After diving deep down into stackoverflow, I have stumbled upon a question. It is somewhat similar to what I'm looking for and it solved my problem. So here's my modified code that works, it display the First name of the currently logged in user.
public void getData(){
string parseUser = ParseUser.CurrentUser.Get<string> ("FirstName");
name.Text = parseUser;
}
I'm working with C# and the .NET 2.0 framework in Visual Studio 2010.
I'm trying to extract a URL which is returned by a web service.
This URL is returned in an array of features containing keys and values. (I think this is similar to what I learned in school is called a hash table).
My intellisense doesn't pick up anything useful and I can't figure out what I'm doing wrong.
This is the code. What goes in serverInfo.FeatureSet[]?
public string wfl_reqURL(string username, string password)
{
MyWorkflow.ServerInfo serverInfo = new MyWorkflow.ServerInfo();
myURL = serverInfo.FeatureSet[];
}
This is how it's described in the WSDL. FeatureSet is being returned as an array with a string key and a string value:
<ServerInfo>
<FeatureSet>
<Feature>
<Key>FileUploadUrl</Key>
<Value>http://localhost/transferindex.php</Value>
</Feature>
</FeatureSet>
</ServerInfo>
Have I provided enough detail about my problem? Most of the information I've found seems to be about how to create such arrays in web services, not select one from a web service as I'd like to do.
Try something like this:
object neededItem = null;
foreach (string item in serverInfo.FeatureSet.Keys)
{
if (item == "FileUploadUrl")
{
neededItem = serverInfo.FeatureSet[item];
break;
}
}
if (neededItem != null)
{
//Do something
}
If you're using c# 3.5 then something in linq like
myURL = serverInfo.FeatureSet.First(o=>o.Key == "FileUploadUrl").Value
The problem was in the data type. Changing the code to this solved the problem, albeit in a messy way. I thought it had something to do with types and how it was defined...either as dictionary or arrays, but it was a bit different than I'd thought...
foreach( MyWorkFlow.Feature feature in serverInfo.FeatureSet) {
if (feature.Key.ToString() == "FileUploadUrl") {
string myURL = feature.Value;
Console.WriteLine(myURL);
}
I'd like to build a site which simply displays the top latest (by date, revision?) "n" commit logs plus other associated info.
What's the best way to do this? I started having a quick look at SharpSvn, but the GET seems to be based on Revision ranges rather than date.
I'd like a simple example for .Net in c# based on any available library which gets the job done.
Since you mentioned using SharpSVN, I happen to have written this in BuildMaster:
private static IList<string> GetLatestCommitMessages(Uri repository, int count)
{
using (var client = new SvnClient())
{
System.Collections.ObjectModel.Collection<SvnLogEventArgs> logEntries;
var args = new SvnLogArgs()
{
Limit = count
};
client.GetLog(repository, args, out logEntries);
return logEntries.Select(log => log.LogMessage).ToList();
}
}