Posts tagged with facebook-graph-api

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"

I'm working on an app using the Threads API from meta. I have created the application successfully on the developer console, and am trying to test access using the Graph API Explorer. I've selected "threads.net" from the endpoint dropdown, and the application I created from the "Meta app" dropdown, but when I try to generate an access token, the approval window appears, I click continue, and then it just says "URL Blocked"

Is there something I'm missing?

When asking adding extra permissions to the scope argument of my FB login button, those permissions aren't added to the access token.

I'm building an app (with Next.js) that let's you schedule posts to a users profile page.

The user I'm testing with has the Role of Tester in my app, so app permissions shouldn't be a problem.

This is my code:

facebook async init code

useEffect(() => {         window.fbAsyncInit = function () {             // @ts-ignore             FB.init({                 appId: process.env.NEXT_PUBLIC_FACEBOOK_APP_ID,                 cookie: true,                 xfbml: true,                 version: process.env.NEXT_PUBLIC_FACEBOOK_API_VERSION, // v20.0             });             // @ts-ignore             FB.AppEvents.logPageView();             // @ts-ignore             FB.getLoginStatus(function (response) {                 console.log('login status:', response)             });         };         (function (d, s, id) {             var js, fjs = d.getElementsByTagName(s)[0];             if (d.getElementById(id)) { return; }             js = d.createElement(s); js.id = id;             // @ts-ignore             js.src = "https://connect.facebook.net/en_US/sdk.js";             // @ts-ignore             fjs.parentNode.insertBefore(js, fjs);         }(document, 'script', 'facebook-jssdk'));     }, []); 

the login button onClick handler:

const loginWithShowListPerm = () => {         // @ts-ignore         FB.login(function (response) {             (async () => {                 console.log('login response:', response)                 if (response.status === 'connected') {                     const params: GraphApiParams = {                         accessToken: response.authResponse.accessToken,                         platformUserId: response.authResponse.userID,                     }                     await saveAccessToken(params);                     const accessTokenData = await getAccessTokenData(params);                     console.log('accessTokenData:', accessTokenData);                     // User is logged in and authorized                     // Execute your function here                 }             })();         }, { scope: 'pages_show_list' }); 

the convertToLongLivedAccessToken backend method this method is called by the server action saveAccessToken

export async function convertToLongLivedAccessToken({     userAccessToken, }: {     userAccessToken: string, }) {     try {         const response = await fetch(`https://graph.facebook.com/${process.env.NEXT_PUBLIC_FACEBOOK_API_VERSION}/oauth/access_token`, {             method: 'POST',             headers: {                 'Content-Type': 'application/json',             },             body: JSON.stringify({                 grant_type: 'fb_exchange_token',                 client_id: process.env.NEXT_PUBLIC_FACEBOOK_APP_ID,                 client_secret: process.env.FACEBOOK_APP_SECRET,                 fb_exchange_token: userAccessToken,             }),         });         const data = await response.json();         console.log('data:', data);         return data.access_token;     } catch (error) {         console.error('Error converting to Long Lived Access Token:', error);         return null;     } } 

node.js script to check token permissions:

 async function main() { try { const response = await fetch(`https://graph.facebook.com/v20.0/me/permissions?access_token=${accessToken}`);         if (!response.ok) {             throw new Error(`HTTP error! status: ${response.status}`);         }              const data = await response.json();              console.log('Data:', data);          } catch (error) {         console.error('Error fetching user permissions:', error);     } } main(); 

Even when adding { scope: 'pages_show_list' } attribute to the login button code, both the short lived and the long lived tokens return this when testing with the check permissions script:

 Data: { data: \[ { permission: 'public_profile', status: 'granted' } \] } 

as you can see, only the default granted 'public_profile' permission is included, the 'pages_show_list' is missing. I would expect there to at least be a mention of the permission, either with status 'granted' or something else.

Help would be greatly apreciated.