Can't convert System.Collections.Generic.List in List<> - c#

I am trying to get a JSON from a API using Dreamfactory on Xamarin.Forms project. I was trying before with their API .net but it doesn't work for my cross-platform so I decided to try it with the TODORest Example they got in [1]: https://github.com/xamarin/xamarin-forms-samples/tree/master/Todo/Todo
I changed the URL to my API one and use the user like empty string and the password for my API key . But when I return the Item to await RefreshDataAsync() tell me a error CS0029 and CS4033 last error means await cant be used in a static but is a async method: public static async Task<List<TodoItem>> RefreshDataAsync().
Can someone help me to find another way to connect to Dreamfactory API or why xamarin give me that errors from the xamarin sample?

Related

Issue with Twitter API possibly Tweetinvi (Forbidden)

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.

Adding public facebook feed to UWP

I have a UWP project in c#/xaml
I'd like to add the feed of a public facebook page to it, without having to log in, no option to comment or anything, just showing the feed, but I only find how to do it using javascript (for example https://developers.facebook.com/docs/plugins/page-plugin )
Is there a way for me to add the javascript to my UWP project, or is there a different way to do this in c#?
You can get the public facebook feed by the /{page-id}/feed in Graph API.
To use the /{page-id}/feed, we should be able to get the access token. We can get it from the app id and app secret in facebook for developers. That you can request the following url to get the facebook feed: https://graph.facebook.com/PAGE-ID/feed?access_token=APP-ID|APP-SECRET.
Then you can use the GetStringAsync of HttpClient to send a GET request to the specified Uri and return the response body as a string in an asynchronous operation.

C# - Facebook SDK time out when get friend more than 1000

I used Facebook SDK to connect with Graph API (get here: https://www.nuget.org/packages/Facebook/) and when received access _token I make a test with the account has 689 friends and it worked as well, but when I switch to another account has more than 3000 friends, it was got an exception and not return anything.
I has been researching for it and someone recommended me to use GetTaskSync() method in FacebookClient class, but I don't understand how to use this function (searched but got nothing).
Please help me, thanks in advance !
This Stackoverflow question describes using bundles to tell Facebook what upper limit to use for number of friends.
Use the Bundle object, call putInt("limit", 5000), then execute a GraphRequest using executeAsync.
https://stackoverflow.com/a/33409920/154186

LinqToTwitter C# library erroring out when calling CreateFriendshipAsync

I have been using LinqToTwitter's CreateFriendshipAsync method since quite a while, but all of a sudden it started to give the following error:
Invalid character '<' in input string
After doing authorization from Twitter when it returns to callback URL, using the returned AccessToken and AccessSecret to initialize the LinqToTwitter's TwitterContext method and twitter client. After that calling the CreateFriendshipAsync passing the twitter username to follow.
It was working fine but today it gave strange error.
Does anyone can tell me what could possibly go wrong.
I am using LinqToTwitter version 3.05, I have tried with latest version 3.1.2, but getting same error.

Google Freebase Api C# .Net Example

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.

Categories