I'm currently trying to migrate an existing server-side application which uses Firebase Cloud Messaging. To my understanding, this NuGet package is suitable for that; I have successfully referenced it in the existing C# project.
However, the documentation available here is indeed a very documented, but does not give a step-by-step example on how to initiate a call. How can I formulate a call to the API? I have done so in the past successuflly with a customized HTTP request, but don't understand how to do this with the API.
Has anyone successully used this API before and could give some insights? Although I use C#, any experience already made with a different language will be appreciated.
Related
I'm starting a side project that will integrate heavily with Facebook. I'm going to use React in the front-end and it will talk to a REST ws made with asp.net core web api.
The idea is that in this API I will make the calls to Facebook.
Basically, I want to: login, get/post messages from Messenger, get/post comments and messages from a business page.
I googled a little and didn't find many resources or examples of how to do this integrations other than the Facebook documentation, that has a lot of stuff and I don't know very well where to look.
I also found this SDK for .NET but it looks a bit dated https://github.com/facebook-csharp-sdk/facebook-csharp-sdk and
So, my question is: Is reading the documentations entirely really the best solution?
If anyone could at least give me a hint where to go I'd be really thankful. Would it be better/easier to integrate with Facebook with other stack than c#/asp.net?
Also, if there's any other API, SDK or something already built in .NET that would help with that I'd be grateful.
Thanks in advance.
I am one of .net developers working with Facebook API more then 5 years and we have tried to use "Facebook SDK for C#". It has more issues then benefits. In result we end up with our own small Facebook API client. Basically it is just a "RestSharp" HTTP library, "Newtonsoft.Json" for serialization/deserialization and couple of generic functions where you supply Facebook API endpoint, and specify what class you expect back as generic parameter.
var accounts = client.Get<Accounts>("me/accounts");
var createResponse = client.Post<CreateResponse>("123456779/feed", postToCreate);
Facebook SDK for C# works great for standard .NET
https://hackerapp.com/net/
https://github.com/facebook-csharp-sdk/facebook-csharp-sdk
As for .NET Core I think you are out of luck at the moment. Unless you want to port it to .NET Core yourself.
Automated Customer Service bots are not uncommon in FB, but code is hard to find. I assume you had setup you App's domain and got it reviewed and approved by FB.
I tried to set a chat-bot with both, python and .NET, and I must say the python Api is much more complete, quick, and less buggy than the C# one. But, as far as I know, only the PyApi has integrated reactions (haven't tried them).
Therefore, you will need to do this manually by using the Facebook Api by sending direct GET/POST request triggered by your ASP.NET, or use some kind of inter-language platform such as IronPython to workaround the problem (which basically assembly the call, add the Key and secret, and CURL-it).
As final remark (not a very motivating one), there is documentation for post reactions, but not for message as you can see here (posts), and here (messenger).
You can perform a lot of the facebook operations on the client side using their javascript SDK.
https://developers.facebook.com/docs/javascript
In regards to getting up to speed on server side API calls from .NET you can check out the facebook graph api explorer. It can be helpful for discovery.
https://developers.facebook.com/tools/explorer/
In case someone is looking for this topic, I had the same needs myself. After not finding a Facebook SDK to use with .NET Core, I've created a new open source .NET Standard unofficial SDK for Facebook: https://github.com/developer82/FacebookCore
I want to communicate with the Google Assistant SDK via C#, and the SDK website said that for languages other than Python, I need to setup gRPC. Are there any good tutorials on this that I can use to get started? Thanks :)
https://developers.google.com/assistant/sdk/reference/rpc/
It should be possible to use assistant API SDK from any language that support gRPC (including C#), but if there is not pre-build assistant SDK available (looks like there is one for python, not sure about other languages), it is a bit more involved to do that.
In short:
The .proto API definitions for all public Google APIs (including assistant API) live in "googleapis/googleapis" github repo:
https://github.com/googleapis/googleapis/tree/master/google/assistant/embedded/v1alpha1
In short, here's what you need to do:
grab .proto definitions for the API from github
generate proto messages/stubs in language of your choice (basically the same as in gRPC tutorials on grpc.io).
authenticate with google using an auth library
(http://www.grpc.io/docs/guides/auth.html)
invoke API calls using a client stub generated in step 2.
Btw, the Google API client libraries are basically a pre-packaged result of these steps, sometimes with a bit of convenience layer on top of it improve the user friendliness of a given API.
Also, usually support for more languages is added to new APIs over time (so at some point there might be and official C# client library).
Does Azure offer full APIs to accomplish all tasks without opening azure portal.
I heard some REST APIs are available but not sure about their coverage.
My questions is can we replace Azure portal completely by our customized enterprise App which actually calls REST APIs provided by Azure.
here is Why I need this strange thing
We need this as our organization is developing a Internal Unified App to manage our resources on all three cloud Azure,AWS and Google Cloud from single point..
The answer to your question is yes. You can certainly do that. As Alex mentioned in his comments, take a look at Azure Service Management API to begin with.
However there are a few things I would like to point out:
As you know there are two portals right now (Live and Preview). Unfortunately both of these portals use different sets of API. Live one uses Service Management API and the Preview one uses Azure Resource Manager (ARM) API. So you have to make sure that you use both of these APIs in your application. Though Microsoft is pushing very hard to make all the APIs exposed through ARM API but there's still a lot of work that needs to be done.
Another thing I noticed is that at times documentation for REST API for certain services is missing though there are ways to find that information. Just keep that in mind if you're building support for these services and not able to find documentation.
I would suggest you start here: https://msdn.microsoft.com/en-us/library/azure/mt420159.aspx and then find out REST APIs for the services you're interested in supporting in your application.
Scope: I am developing a mobile application using Xamarin (C#) to target both Android and iPhone (initially Android). The application logic is separated out in to a PCL (C#) where possible to ensure maximum code reuse. The application integrates with the YouTube Data API v3 for the purpose of rating retrieved videos and allowing subscription to a channel.
Background: As per the documentation (http://developer.android.com/google/play-services/auth.html) I have used the suggested approach to generate an OAuth2 token for the authorised requests from Android, using the AccountManager.getToken method and this works fine and returns a token.
The next step is to make requests using this token (let's take rating a video as an example). My initial idea was to utilise the .NET client library for the YouTube Data Api (https://developers.google.com/api-client-library/dotnet/get_started). However, it seems that this would take us through the whole authorisation process once again and would likely require a web view redirect or similar. I had hoped that there may be a way to use a token which had already been retrieved to create the credential object or create the service from directly, but it doesn't appear to be the case.
The second problem I have found with the client library is that not all of the classes appear to be referenced when adding the NuGet package, namely the GoogleWebAuthorizationBroker. Additionally, as we are in a PCL we are limited with common objects such as FileStream which is utilised in the documented examples (https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth). I did try to use this library from a non-PCL project also to confirm that it wasn't just the limited references in the PCL which were responsible (for the GoogleWebAuthorizationBroker reference issue).
The other option therefore was to look at manual construction of the URL and then posting the data to make the HTTP request ourselves. This too has met with limited success similar to the question listed here: Like video with access token on YouTube using YouTube Data API v3?, which doesn't appear to be answered (suggestion to use the client api). Is this method supported, and if so are there some documented .NET examples? This method would allow me so get the token natively (on android, iphone) and then pass it to a PCL library where I could make the requests, which would be preferable.
Question: So my question is given the scope of what I am trying to achieve here what would be the approved/suggested approach. Clearly the more I can do within the PCL the better from a code reuse point of view, but right now I'd be fairly satisfied with an approach that will actually just work for Android. If anyone has any examples of successfully making authenticated requests to the YouTube Data Api (v3) from Android that would also be useful. I feel like I've trawled through a lot of the documentation to this point over a number of days but not found anything definitive to say "this is how you should do it".
Thanks in advance for any help.
Well, I wouldn't necessarily deem this the answer to my question, however, it is the approach I have taken, so thought I would report back. I have kept the OAuth2 token generation code inside the Xamarin Android project and then pass that on to a PCL which has a repository to deal with the YouTube integration. As there are only a few calls I need to make (ratings, subscriptions and comments) I have elected to manually construct the POSTs via HttpClient and proceed that way.
Perhaps not as elegant as the client library integration but gets the job done. For reference this is made a lot easier if you use the Google OAuth Playground (https://developers.google.com/oauthplayground/) first to get the token and confirm the correct JSON for your request.
If anyone has any problems with this approach then let me know and I can post specific service calls as an example.
From what I can gather, this isn't what google-api-dotnet-client is for.
If you look at the source code (https://github.com/google/google-api-dotnet-client), you can see that GoogleWebAuthorizationBroker is defined for Windows Store, WP 8 etc.
This suggests that the library is intended for .NET clients running on Microsoft operating systems, rather than Android, iOS etc.
These might be the droids you are looking for:
https://github.com/xamarin/GooglePlayServicesComponents (Android)
https://github.com/xamarin/GoogleApisForiOSComponents
They are Xamarin wrappers around the Google SDK for each platform.
This makes sense because of the way Google APIs are called on Android. Rather than rely on a client secret which one should not embed in the application, the you register the app's signature against the "installed app" client ID. The operating system then provides this key when calling google services. You won't get that functionality in a PCL :)
It's unclear to me how I can do an API request to retrieve data for the YouTube API.
I used this code (http://zavitax.wordpress.com/2012/12/17/logging-in-with-google-service-account-in-c-jwt/) to get an access token. The next step is: https://developers.google.com/youtube/v3/guides/authentication?hl=en#OAuth2_Calling_a_Google_API. I don't know how to use www.googleapis.com/youtube/v3/video?access_token=ACCESS_TOKEN in my application to retrieve data. How can I use my access token to request data from the API?
The recommendation is to use the Google APIs Client Library for .NET. As the webpage for the client library states, it's still undergoing active development and isn't as far along as the client libraries for some of the other languages. It still should be usable, though.
There are specific generated classes to use with the YouTube Analytics API and the YouTube Data API v3. You'll need to download those
Our C# sample code is unfortunately scarce, but there is one example of doing a video search. Hopefully that is enough to get you started.
To do anything with the Analytics API, and any write operations with the Data API, you'll need to be authenticated with OAuth 2. There's an explanation of how to do that in the client library docs.
The client library is maintained by a team within Google, but it's not the YouTube API team, so the best way to follow up with the maintainers with any issues you find is to use the public issue tracker.