Posts under category Meta & Facebook

We are receiving following error: (#10) To use 'Oembed Read', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Oembed Read' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.
our app has received advanced access to Oembed Read a few months ago already and has worked for the past months, now all of a sudden we need another review to get access? Is there another issue that's causing this or is this a facebook issue?

As a heads up, we've seen that since 2024-01-18 20:26 (UTC) the comment delete endpoint returns
[]
isntead of
{
"success": true
}
when successfully deleting comments.
The docs are clear that it is supposed to be the latter https://developers.facebook.com/docs/graph-api/reference/v18.0/comment#deleting
Can anyone confirm this?
Workaround is to just not check the result diligently.

I'm having issues trying to download media files from the WhatsApp Business API. Following along with their documentation (https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#download-media) they provide a cURL command that is successful in downloading a media file when used - however, the same request (I think) when done using NodeJS' fetch returns text/html responses with vague error wording and a 200 status code.

# Successful cURL: curl "https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=281274211304477&ext=1705672414&hash=ATtH6AOGFu0RqEpENicHUg8HCUkVfwGzfrHVCdiE7J8AUA" --header "Authorization: Bearer ..." 
// Successful cURL from child_process.exec: exec(   `curl --location "${mediaURL}" --header "Authorization: Bearer ..."` ); 
// Unsuccessful fetch: fetch(   "https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=281274211304477&ext=1705672414&hash=ATtH6AOGFu0RqEpENicHUg8HCUkVfwGzfrHVCdiE7J8AUA",   { headers: { Authorization: "Bearer ..." } } ); 

Suggestion from WhatsApp Cloud API Receiving Images from Users Error is also unsuccessful, unfortunately:

// Also unsuccessful fetch: fetch("https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=281274211304477&ext=1705672414&hash=ATtH6AOGFu0RqEpENicHUg8HCUkVfwGzfrHVCdiE7J8AUA", {   headers: {     Authorization: "Bearer ...",     "User-Agent": "curl/7.64.1",   }, }) 

Note: The lookaside.fbsbx.com URLs are all retrieved successfully from the WhatsApp Business APIs.

Per the documentation, a 404 error should occur if the link has expired, however, this isn't the case - and the access token hasn't expired either. Looking through the Community Forums, specifically https://developers.facebook.com/community/threads/1367000994138329/?join_id=f25971b6b4f9cc4, many conversations suggest that the User-Agent header should be spoofed - yet this doesn't seem to work either, although tweaking the User-Agent header within Postman yields varying results.

Successful in Postman:

Unsuccessful when User-Agent is adjusted in Postman:

Unsuccessful when User-Agent is removed in Postman:

Any suggestions would be greatly appreciated. I was unable to use the Meta for Developers' "Report a bug" forms as support appears to be unavailable for WhatsApp Business APIs.

Also seen posts: 1, 2 on StackOverflow; 1, 2, 3, 4, 5, 6 on Meta Support Forums.

When I click to sign the "message_echoes" field, the following message is displayed "You could not subscribe to some of the fields requested due to a permissions error"
Can someone help me with this, I need to receive all the messages, including the ones I send to whatsapp myself.

I am working on a project using FastAPI to handle incoming WhatsApp messages and respond to them. I've set up the webhook, and I can successfully receive messages. However, I'm encountering issues when trying to send a response back to the user using the WhatsApp Business API.

Here is the relevant part of my code:

from fastapi import FastAPI, Request, HTTPException, Query from fastapi.responses import JSONResponse from pydantic import BaseModel import requests app = FastAPI() VERIFY_TOKEN = "tourism"   class WhatsAppEvent(BaseModel):     message: dict WHATSAPP_API_ENDPOINT = "https://graph.facebook.com/v18.0/***(Entered my phone number ID)/messages" WHATSAPP_API_TOKEN = "***(Entered my API access token)" @app.post("/") async def handle_post_request(request: Request):     # Process the incoming POST request here     data = await request.json()     print("Received POST request data:", data)     # Send a response     return {"status": "success", "message": "POST request received"} @app.get("/") def verify(request: Request):     mode = request.query_params.get('hub.mode')     challenge = request.query_params.get('hub.challenge')     token = request.query_params.get('hub.verify_token')     if mode and token:         if mode == 'subscribe' and token == VERIFY_TOKEN:             print("WEBHOOK_VERIFIED")             return JSONResponse(content=int(challenge), status_code=200)         else:             raise HTTPException(status_code=403, detail="Verification failed")     return {"code": 200, 'message': 'test'} @app.post("/incoming-message") def receive_message(event: WhatsAppEvent):     try:         user_message = event.message['text']         sender_id = event.message['sender']['id']         bot_response = f'You said: {user_message}' #sending an echo message                  # Prepare response for WhatsApp         response_data = {             'recipient': {'id': sender_id},             'message': {'text': bot_response}         }         send_whatsapp_message(sender_id, bot_response)         return JSONResponse(content=response_data, status_code=200)     except Exception as e:         raise HTTPException(status_code=500, detail=f"Error processing message: {str(e)}")      def send_whatsapp_message(recipient_id, message_body):     headers = {         'Authorization': f'Bearer {WHATSAPP_API_TOKEN}',         'Content-Type': 'application/json'     }     data = {         'phone': recipient_id,         'message': {             'text': message_body         }     }     try:         response = requests.post(WHATSAPP_API_ENDPOINT, headers=headers, json=data)         response.raise_for_status()  # Raises HTTPError for bad responses         print("WhatsApp API response:", response.text)  # Add this line for debugging         return response.json()  # If you want to return the API response data     except requests.exceptions.HTTPError as errh:         print("HTTP Error:", errh)         raise HTTPException(status_code=response.status_code, detail=f"HTTP Error: {errh}")     except requests.exceptions.RequestException as err:         print("Request Error:", err)         raise HTTPException(status_code=response.status_code, detail=f"Request Error: {err}") if __name__ == "__main__":     import uvicorn     uvicorn.run(app, reload=False, host="0.0.0.0", port=8000) 

I have verified that the webhook is working (WEBHOOK_VERIFIED is printed in the console), and I can see the incoming messages in the logs. However, the send_whatsapp_message function does not seem to be sending messages successfully.

The response from the WhatsApp API is as follows:

WEBHOOK_VERIFIED INFO:     2a03:2880:23ff:5::face:b00c:0 - "GET /?hub.mode=subscribe&hub.challenge=1310749767&hub.verify_token=tourism HTTP/1.1" 200 OK Received POST request data: {'object': 'whatsapp_business_account', 'entry': [{'id': '**(My ID)', 'changes': [{'value': {'messaging_product': 'whatsapp', 'metadata': {'display_phone_number': '**(My number)', 'phone_number_id': '**(My Phone number ID)'}, 'contacts': [{'profile': {'name': 'Rishikesh Dasari'}, 'wa_id': '**(recipient Number)'}], 'messages': [{'from': '**(recipient Number)', 'id': 'wamid.HBgMOTE5MzkwMzYwMjYyFQIAEhgWM0VCMEMyRUU3MzQ4Q0VCNjFGQUIzRgA=', 'timestamp': '1705643757', 'text': {'body': 'hello'}, 'type': 'text'}]}, 'field': 'messages'}]}]} INFO:     2a03:2880:20ff:b::face:b00c:0 - "POST / HTTP/1.1" 200 OK 

I have double-checked the WhatsApp API endpoint, token, and the structure of the request, but I'm still unable to send messages. I suspect there might be an issue with my send_whatsapp_message function.

Can someone please review the code and provide insights on what might be causing the problem? Additionally, if there's a better way to handle sending WhatsApp messages in FastAPI, I'm open to suggestions.