Posts tagged with facebook-graph-api

I am working on an app that helps in publishing the post on different platforms in a single go. User has to write about their post and add pictures if they want and then select the social media they want to post on like they can select facebook and instagram or facebook,Instagram and X and when the click the button based on the selection post should be publish on there social media account.

What Problem I am facing?

I am able to create a button that helps user to login to facebook and thats working perfectly. But when it comes to publishing a post it doesn't work. Please let me know what I can do to make that code run??

Here is the code snippet for publishing post to facebook.

private void postToFacebook(String token, String msg) {         String url = "https://graph.facebook.com/v17.0/me/feed";         StringRequest stringRequest = new StringRequest(Request.Method.POST, url,                 new Response.Listener<String>() {                     @Override                     public void onResponse(String response) {                         // Handle success                         Log.d("FBResponse", response);                         Toast.makeText(MainActivity.this, "Post Successful!", Toast.LENGTH_SHORT).show();                     }                 }, new Response.ErrorListener() {             @Override             public void onErrorResponse(VolleyError error) {                 // Handle error                 Log.e("FBError", error.toString());                 Toast.makeText(MainActivity.this, "Failed to Post: " + error.getMessage(), Toast.LENGTH_LONG).show();             }         }) {             @Override             protected Map<String, String> getParams() {                 Map<String, String> params = new HashMap<>();                 params.put("message", msg);                 params.put("access_token", token);                 return params;             }         };         RequestQueue queue = Volley.newRequestQueue(this);         queue.add(stringRequest);     } 

This is the error I am getting when I am trying to publish a post.

2024-09-07 07:34:41.2465642-5734  Volley                  com.example.post                     E  [83] NetworkUtility.shouldRetryException: Unexpected response code 403 for https://graph.facebook.com/v17.0/me/feed 2024-09-07 07:34:41.416790-790   StatusBarIconController com.android.systemui                 D  ignoring old pipeline callbacks, because the new mobile icons are enabled 2024-09-07 07:34:41.4845642-5734  Volley                  com.example.post                     E  [83] NetworkUtility.shouldRetryException: Unexpected response code 403 for https://graph.facebook.com/v17.0/me/feed 2024-09-07 07:34:41.4865642-5642  FBError                 com.example.post                     E  com.android.volley.AuthFailureError 

I'm making a request here:

https://graph.facebook.com/v20.0/<ig-hashtag-id>/top_media?user_id=<ig-user-id>&fields=id,caption,media_type,media_url,permalink 

example response:

{     "data": [         {             "id": "17887284382178689",             "caption": "Visual literature of Kalinga's interpretation of nature through geometric patterns. Propylene ink on wood.",             "media_type": "IMAGE",             "media_url": "https://scontent-mnl1-2.cdninstagram.com/v/t51.2885-15/25008622_432606043809405_4524106124818907136_n.jpg?_nc_cat=110&ccb=1-7&_nc_sid=18de74&_nc_ohc=BsfOfjgpxugQ7kNvgGvos4J&_nc_ht=scontent-mnl1-2.cdninstagram.com&edm=APCawUEEAAAA&oh=00_AYDeM3F_FCkCYs9CO2eALcn-1Zc8cXRjDszE9bUIKvWYMA&oe=66E0275E",             "permalink": "https://www.instagram.com/p/Bc6461zHsE7/"         },         {             "id": "17866280464216878",             "caption": "\"Traversing Tabuk City to the sleepy town of Tinglayan is one of the roughest road I'v ever been to. Composed of narrow roads and limited pathways, this road is not for the faint hearted. You need to trust the driver maneuvering the vehicle and hopefully he brings you safely to your destination. .\n\nThe long hours of travel, there are no phone signals, the only thing you need to focus on is the view around you.\" 📸 jpxdavid",             "media_type": "IMAGE",             "media_url": "https://scontent-mnl1-2.cdninstagram.com/v/t51.2885-15/27894116_147572912599336_2290924483260710912_n.jpg?_nc_cat=109&ccb=1-7&_nc_sid=18de74&_nc_ohc=XIrmLk4n-EMQ7kNvgHJqdp5&_nc_ht=scontent-mnl1-2.cdninstagram.com&edm=APCawUEEAAAA&oh=00_AYAAY49IH_uTMezzet35bt6n289oRKLOoAdNT1HijQMBJA&oe=66E0271A",             "permalink": "https://www.instagram.com/p/BfkudLeFQiL/"         }    ] } 

but I want to the location of the photo back. how can I do this? by location I mean the little string that appears above the photo in the feed

How to track user engagement on Facebook? The goal is to monitor and count engagement for each individual user—tracking the number of likes, comments, and shares, and identifying which specific posts they interacted with

The goal is to monitor and count engagement for each individual user—tracking the number of likes, comments, and shares, and identifying which specific posts they interacted with.

I am trying to create a slider for the feed of a Facebook page with slider revolution. When I try to link the Facebook account to the slider I get this error: "Facebook API error: error getting access token for page data", while the Instagram account bound to that page works.

I have also tried to create the token manually from developper.facebook.com with API Graph and inserted the token into the slider, but I get this other error: Make sure that the stream settings are prorerly selected in Module General options > Content > Stream Settings In the API Graph tool in the me/accounts endpoint I get this result:

{   "data": [     {       "access_token": "my token",       "category": "Organization",       "category_list": [         {           "id": "my ID",           "name": "My organization"         }       ],       "name": "My Page name",       "id": "page ID",       "tasks": [         "ADVERTISE",         "ANALYZE",         "CREATE_CONTENT",         "MESSAGING",         "MODERATE",         "MANAGE"       ]     }   ],   "paging": {     "cursors": {       "before": "QVFIUmQ3bVNJT05ZATVREaFp3ejRRRzdreHg5Q3pnV0xXbFFmWXk2ZAUo3Mm9lZADhTN0c5YnF2QTBienJKWG1tZAy0tXzhRZA0lhUGEzcVVzVkhNcTRzQ3I1R0N3",       "after": "QVFIUmQ3bVNJT05ZATVREaFp3ejRRRzdreHg5Q3pnV0xXbFFmWXk2ZAUo3Mm9lZADhTN0c5YnF2QTBienJKWG1tZAy0tXzhRZA0lhUGEzcVVzVkhNcTRzQ3I1R0N3"     }   } } 

In WordPress I disabled all the plugins and custom theme, but still have error. What could be the problem? Thank you any help

I have a Facebook app running in production, and I've created a system user within Facebook Business Manager. After generating a system user access token, I have also generated a user access token for the system user. However, the API response only returns the page ID and not the page access token. What steps should I take to ensure that the system user has the necessary permissions, and how can I retrieve the page access token successfully?

I generated a system user access token and used it to call the Facebook Graph API to retrieve the page access token. I expected the API to return the page access token, but instead, it only returned the page ID. I was expecting the access_token field in the response but did not receive it.

Here is the CURL used to fetch the page access token :

curl -X GET "https://graph.facebook.com/v19.0/{page_id}?fields=access_token&access_token={user_access_token_or_system_user_access_token}"