Currently, I have to post a Tweets (messages ) to the Twitter account. Im using TweetSharp 2.3.1.
Following is my code :
var service = new TwitterService(ConsumerKey, ConsumerSecret);
service.AuthenticateWith(Token, TokenSecret);
TwitterStatus result = service.SendTweet(new SendTweetOptions
{
Status = "Hello, world!"
});
But, Every time Im getting errror: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll. Though my credentials correct but gettting above error while posting.
Kindly, assist me if anyone knows...
You need to check that you have Read, write, and direct messages access level.
If not then change access level into Read,write and direct message and re-create access token
It seems that TweetSharp is not being maintained anymore. It has lots of issues with Twitter API 1.1 and you may expect several exceptions while using it. I suggest you try to install TweetSharp-Unofficial version insted of Tweetsharp then try to run your application. I faced similar issues with TweetSharp and that solution fixed all my issues.
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 am trying to integrate Adyen in a .net application.
Downloaded the sample code from their Github repository and hardcoded the api-key, merchant and client keys in the code to make sure they are getting populated.
Running the code from my localhost
I am getting this error
{"status":401,"errorCode":"000","message":"HTTP Status Response - Unauthorized","errorType":"security"}
at this line:
var res = _checkout.Sessions(sessionsRequest);
Sample code is here
https://github.com/adyen-examples/adyen-dotnet-online-payments
Any idea of what I am missing?, anyone faced the same issue?
Thanks!
Thank you, i was able to get successful calls after checking how those keys are set to the environment variables. Also Client key is important.
Background information:
I'm trying to create a PoC for Google Cloud Vision API using their .NET library.
What I have done:
Create a simple console apps with the following code for Vision API.
GoogleCredential credential = GoogleCredential.FromFile(ConfigurationManager.AppSettings["GoogleCredentialFile"]);
Grpc.Core.Channel channel = new Grpc.Core.Channel(Google.Cloud.Vision.V1.ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials());
var client = Google.Cloud.Vision.V1.ImageAnnotatorClient.Create(channel);
var image = Google.Cloud.Vision.V1.Image.FromFile(#"C:\Users\u065340\Documents\sample.jpg");
var response = client.DetectLabels(image);
foreach (var annotation in response)
{
if (annotation.Description != null)
result = annotation.Description;
}
Problem:
The line client.DetectLabels(image) gets stuck for a long time before ultimately throwing the error Deadline Exceeded.
My code sits behind a corporate proxy, but I have validated that it is not blocking internet access because I can call https://vision.googleapis.com/$discovery/rest?version=v1 from the same apps and get its JSON response just fine.
Any suggestions?
After digging around through github issues related to proxies as suggested by Jon Skeet, I found that Google Cloud Client APIs can be generally divided into 2 categories (Ref: here): REST-based HTTP 1.1 with JSON and gRPC.
For APIs associated as REST-based, there should be no issue with proxies. The problem starts to appear when we are using gRPC-based APIs such as Google Cloud Vision and Google Speech. In gRPC, we need to explicitly provide our proxy server information.
For those using Java Client, it seems we still can't set proxy properly because it will eventually be ignored, and causing the Deadline Exceeded error. This issue is already well known and can be found at here and further traced into here.
The Google team has determined that it is indeed a bug, and the status remains Open.
As for C# Client, we can set proxy information using gRPC Environment Variables which is documented in here. The code is Environment.SetEnvironmentVariable("http_proxy", <your_proxy_server>);
After I set the http_proxy environment variable pointing to my proxy server, all is well again. I get the expected output "This API needs Billing Account".
Many thanks to Jon Skeet for pointing me in the right direction :D
I am using a C# .NET 2.0 winform in 2010, I have added the ability for a user to log in and post comments. I copied the .NET developer guide in how to post comments but I am getting random but frequent exceptions when trying to post comments. At first I thought it might be because there is some issue with using a google e-mail instead of the youtube log in name, to get around this when a user succesfully logs in I request the profile, get the user name and create a new youtube settings class and give the appropriate credentials with the users profile name. This however hasn't resolved the issue, the comments still work sporadically. Here is the code that basically handles logging in.
youtubeService.setUserCredentials(userBox.Text, passwordBox.Text);
try
{
String strAuth = youtubeService.QueryClientLoginToken();
}
catch (Exception ex)
{
}
The above code is in a seperate form, the form that hosts the youtube video basically looks to see if this process has been completed and grabs the username, password used to log in and sets the new settings:
m_LoggedInSettings = new YouTubeRequestSettings(myappname, mydevkey, username, password);
m_LoggedInRequest = new YouTubeRequest(m_LoggedInSettings);
This then used to add a comment:
Comment userComment = new Comment();
userComment.Content = commentText;
m_LoggedInRequest.AddComment(youtubevideo, userComment);
When it fails I get the following:
{"Execution of request failed: https://gdata.youtube.com/feeds/api/videos/t-8K8Hj8bxE/comments"}
With the following info:
{"The remote server returned an error: (403) Forbidden."}
Status code:
System.Net.HttpStatusCode.Forbidden
Status description:
Forbidden
A few things come to mind, I do not have a proper log out that sends anything to youtube implimented at the minute (is this needed?), so it may be that I've logged in multiple times and that is somehow flagging on youtubes side? It could also be that I am essentially creating new settings and request objects that weren't used to get the video/comments and maybe the video taken from the normal settings file (with no log in) is giving problems or something like that? To be honest, I haven't got a clue what is wrong and any help would be greatly appriecated.
Okay, so I figured out that the reason they were erroring is because I was trying to post consecutive comments too fast, however I don't know what the timeout is for being able to post more comments.
My app has permissions to "like" something on FB on a user's behalf. Using the Facebook C# SDK (5.4.1), here's what I wrote:
Facebook.FacebookClient fb = new Facebook.FacebookClient(AccessToken);
object o = fb.Get("1234567890_12345678901234567/likes");
dynamic parameters = new ExpandoObject();
dynamic success = fb.Post("1234567890_12345678901234567/likes", parameters);
The second line is superfluous and creates an unnecessary round-trip, as we're not interested in the other "likes" on the same object. However, without it, fb.Post fails and throws "The remote server returned an error: (400) Bad Request."
Is this a bug in the C# SDK, or a bug in the graph API, or is it by design?
Note that it's possible to POST to /comments without a previous GET.
Yes, it should be possible to do post commands without a get. Strangely enough, my like code with the 5.4.1 does not require the extra GET directly before the POST for doing a like. Maybe somewhere else in my app's flow I've already done some sort of GET via the API. However, I'm going to investigate my DELETE problem with me/permissions that I'm encountering (http://stackoverflow.com/questions/8598614/facebook-c-sharp-api-return-400-when-deauthorizing-app) and see if a get to the me/permissions first will help resolve that issue.