Posts under category facebook-graph-api

I tried to get total_video_views_by_country_id from the Facebook Graph API and have some error

I tried to get total_video_views_by_country_id from the Facebook Graph API using the endpoint

GET /v20.0/{video-id}/video_insights HTTP/1.1  

via the Graph API Explorer 510171338137924/video_insights/metric=total_video_views_by_country_id However, when I attempted this on the Graph API Explorer, the result was

{   "error": {     "message": "(#100) The value must be a valid insights metric",     "type": "OAuthException",     "code": 100,     "fbtrace_id": "AA1wczXhtw-h7XE8msmeQgY"   } } 

Description
I've been working on processing leads through our system and encountered an issue. I've enabled webhooks on my app, subscribed to leadgen, and provided my callback redirect URL. However, whenever I create a lead, it should be sent to my server, but when I track the status, it shows "failed" with the message "webhook.delivery.rejected." I've looked in the logs of my application but the request is not entering my server at all. I'm trying to understand why this is happening and how to ensure my configuration is correct for receiving leads.

Previously, I completed the process manually by subscribing to each webhook with a seperate app, and it worked fine. Now, I want to programmatically do this using Facebook’s API and one app. Here's the request I'm using to subscribe to the webhook for leads: curl -X POST "https://graph.facebook.com/{page_id}/subscribed_apps?subscribed_fields=leadgen&access_token={page_token}" -H "Content-Type: application/json" -d '{ "override_callback_uri": "https://api-development.recrubo.app/facebook/webhooks/{organization_id}", "verify_token": "{verify_token}" }'

Debugging
Here are my debugging steps so far: I've used the Facebook sharing debugger tool with my callback URL, which returns a 200 status. You can check the results here: Debugging Results..

I've used the Lead Ads RTU Debug Tool to send a test lead to our server but it isn't arriving at my server.

Question
Is there any place to see more error logging in the developer app?

Code
The perform method calls all subsequent calls . It first fetches the user_id which is used to check what pages the user has given us access to. It then fetches the page_access_tokens for all the accessible pages. It then loops through the pages and subscribes to the webhooks.

 def perform   @user_id = get_user_id   @pages = get_page_access_tokens   @pages.each do |page|     @facebook.subscribe_to_webhook(page[:id], page[:token])     token = @facebook.get_long_lived_access_token(page[:token])     options = {       ad_account_id: @ad_account_id     }     @access_token ||= @organization.access_tokens.create!(token: token, options: options, name: 'Meta', user_id: @user_id)   end   @access_token end def get_page_access_tokens(user_id, access_token)   response = Faraday.get("#{ENV.fetch('FACEBOOK_GRAPH_API')}/#{user_id}/accounts") do |req|     req.headers['Content-Type'] = 'application/json'     req.params['access_token'] = access_token   end   raise "Unable to get page access token server responded with #{response.body} and status #{response.status}" unless response.success?   data = JSON.parse(response.body)   page_data = data['data']   page_data.map { |page| { id: page['id'], name: page['name'], token: page['access_token'] } } end def subscribe_to_webhook(page_id, page_token)   response = Faraday.post("#{ENV.fetch('FACEBOOK_GRAPH_API')}/#{page_id}/subscribed_apps?subscribed_fields=leadgen") do |req|     req.headers['Content-Type'] = 'application/json'     req.params['access_token'] = page_token     req.body = {       override_callback_uri: "#{ENV.fetch('API_URL')}/facebook/webhooks/#{@organization['id']}",       verify_token: {local_token}     }.to_json   end   raise "Unable to subscribe to leadgen webhook server responded with #{response.body} and status #{response.status}" unless response.success?   response end def get_user_id(access_token)   response = Faraday.get("#{ENV.fetch('FACEBOOK_GRAPH_API')}/me") do |req|     req.headers['Content-Type'] = 'application/json'     req.params['fields'] = 'id'     req.params['access_token'] = access_token   end   raise "Unable to get user id server responded with #{response.body} and status #{response.status}" unless response.success?   JSON.parse(response.body)['id'] end 

Edit 1

After the comment of CBroe we have looked further in to the subscription and have added validation for these subscriptions. We see the following data:

  • graph.facebook.com/v20.0{page_id}/subscribed_apps

  • graph.facebook.com/v20.0{app_id}/subscriptions

I'm working with the Meta Graph API and trying to filter results based on a subfield within a nested object. Specifically, I want to retrieve ad accounts with their associated campaigns, but only include campaigns that have a stop_time greater than a certain timestamp.

Here's the query I'm attempting to use:

me/adaccounts?fields=id,name,campaigns{id,name,stop_time}&filtering=[{field:'campaigns.stop_time',operator:'GREATER_THAN',value:'1721630725'}] 

Unfortunately, this doesn't seem to work. I suspect I'm not structuring the filtering correctly for subfields.

Can someone explain how to properly apply filters to subfields in Meta Graph API queries? Is it possible to filter nested objects directly within the main query, or is there a different approach I should take?

Any guidance or examples would be greatly appreciated!

I'm trying to get comments from Facebook live_videos with Facebook SSE.
Despite I can easily retrieve comments with the {live-video-id}/comments graph api using my test app's page access token, I can't make the SSE to work with the same access token.
Trying to connect with eventsource (code below) keep giving { type: 'error', status: 404, message: 'Not Found' }

async execute() {     this.es = new EventSource(       `https://streaming-graph.facebook.com/${live_video_id}/live_comments?access_token=${page_access_token}`,     );     this.es.onopen = (ev) => {       console.log('onopen', ev);     };     this.es.onmessage = (ev) => {       console.log('onmessage', ev);     };     this.es.onerror = (err) => {       console.error(err);     };   } 

Is there anything else that I'm still missing to get the SSE to work?

i'm working on an extension for OpenCart to bind social account to OpenCart Account i'm keep facing this issue:

Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request 

i'm sure that the redirect_uri is the same since i'm refrencing the same class variable in step 1 and step 2 of the Facebook login process but still got the same issue.

i had tested all solution suggested by people but none worked. here's my code and a screen shot of "Valid OAuth Redirect URIs"