Posts tagged with .net-core

I am stuck with the Webhook endpoint where I receive the Facebook feeds.

I need to create an API to get the Facebook feeds (comments, like, etc) which are made on my Facebook page.

By following the steps, I have created a facebook app with the developer account. With webhook added

Webhook Added

After that I went to the settings page.

Since I want the feeds, I have select the Page from the dropdown and clicked subscribe. The I need to enter the callback URL.

From my API side, I have created a .NET Core 5 application. Then create a Get and Post method called Webhook. Since I need an https:// connection, I have installed ngRok and setup the test API. And the GET method will return the challenge:

[HttpGet("webhook")] public async Task<IActionResult> Receive([FromQuery(Name = "hub.mode")] string hubMode,                                    [FromQuery(Name = "hub.challenge")] int hubChallenge,                                    [FromQuery(Name = "hub.verify_token")] string hubVerifyToken) {     return Ok(hubChallenge); // this is working... no issue here } 

Back to the Facebook side.

I have added the callback URL after clicking subscribe and got Challenge key in my API Get method. Once its done I need to select the fields i need to subscribe i.e.; feed in order to get the Facebook page response.

Feeds

Then i need to setup permission so, i have subscribed to permission dropdown. Added the callback URL, get the Challenge key and subscription is complete. After that subscribed to pages_manage_metadata , pages_show_list and pages_manage_engagement(although document didn't mention pages_manage_engagement).

After that Went to facebook graph explorer and done the subscription to feed using the page access token https://graph.facebook.com/{page-id}/subscribed_apps?subscribed_fields=feed&access_token={page-access-token}

subscribe to page

This is also done and its says true

I check with the GET method to see whether it is complete and its says feed is in subscribed list Subscribed fields

But after this everything stops :(

When i click the test button its not sending any feed to my Post method in my API.

So i used the graph explore API to comment the Post and post is done , but no webhook response tried comment manually but no response.

So i thought maybe some issue with my API Post endpoint i have created. So i tested with Postman and the request is going through.

I changed by computer to my laptop with different network(you need to try everything possible), still no response.

So Just for the testing i subscribed to the Messaging option in facebook, just to check whether its an issue with the Page. The thing is i got a response to my Post method, so the messaging webhook is sending to the POST method. That means my API end point is correct.

So i thought something to do with by permission, so i enabled all permissions related to the page and tried, but no response.

I changes my facebook account to some other account, not working.

Then i tried with an account with facebook business enabled, no luck

I have tried changing the Permissions in the page, still no luck.

I tryed the gemini,chatgpt 3.5 and 4 ... no luck. asked in the facebook community...that place is kinda dead.

The main issue is i am not even getting any response when i click the Test button. Most of the online issues, they atleast get a hit from test.

So next thing to do is review the app and then test. but when i am in the review page , they are saying we need to test the app well before we go to review. So i an not sure what to do now.

Am i missing something? Any help would be valuable.

I dont know whether its a facebook bug or not. Because some document say

you need if the Page has not disabled the App platform in its App Settings. But in that page there is a turn on button, but it will change its status once we click it, but it will go back to the original state when we refresh the page. App Settings page

If anyone faced this issue and manage to solve this please help. i have been on this for quiet a while and i don't know what to do next.

Thankyou

  UserCredential credential;       using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))       {         credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(             GoogleClientSecrets.Load(stream).Secrets,             // This OAuth 2.0 access scope allows for full read/write access to the             // authenticated user's account.             new[] { YouTubeService.Scope.Youtube },             "user",             CancellationToken.None,             new FileDataStore(this.GetType().ToString())         );       } 

Using the code I shared above, I can renew the duration of the refresh token and create a campaign through Google Ads SDK (for Net 5 application) without any problems, but when I launch the same application in Azure Containers, I get a "Token Expire" error.

I will be very happy if you can help me with this behavior difference. Thank you in advance.

Kind regards

The Company I work with has many clients who uses Google Ads to do marketing for their websites. The company wants to use client's data for Analysis. I am given a project to integrate Google Ads API using C# to get all the data such as Campaigns etc from Google ads and move it to our system for each client. I am only given developer token and customerID for Clients. such as

  1. Customer ID for Client A
  2. Customer ID for Client B

I am bit lost when I went through the google ads API documentation. In the documentation, the OAuth2.0 needs creating in order to use client library which would generate client ID and Client Secret, Refresh token to integrate the API. My question is. Do I need to create OAuth2.0 for each client or do I need to ask my company to generate Client ID and secret in company's Manager Account or Client that uses Google ads would provide me these?

The following Link I found to create OAuth2.

https://developers.google.com/google-ads/api/docs/oauth/cloud-project

This is what I believe would require in C# Content can be found at https://developers.google.com/adwords/api/docs/guides/first-api-call#.net_1

Would highly appreciate if any one can help me what actually I need to configure google ads using C#

I have added the NuGet Google.AdWords 24.10.1 package to a .net core console app. In the SDK documentation they say that .net core is supported. The problem is that the library functions crash on first call with tho following error:

Could not load type 'System.Web.Hosting.HostingEnvironment' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.":"System.Web.Hosting.HostingEnvironment"}

I cant understand if this package is supported or not in the core app?

This line causes a crash: AdWordsUser user = new AdWordsUser();