diff --git a/api/send_media_message_debug.log b/api/send_media_message_debug.log index 2c59913..f779560 100644 --- a/api/send_media_message_debug.log +++ b/api/send_media_message_debug.log @@ -290,3 +290,39 @@ [2026-02-21 07:23:27] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSOEQ4MjMwMUQ2QThCQTcwNjgzAA=="}]} [2026-02-21 07:23:27] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSOEQ4MjMwMUQ2QThCQTcwNjgzAA=="}]} [2026-02-21 07:23:27] Saving to DB - content: DOCUMENTACI‡N_SITIO_XIMENACAICEDO.pdf, media_url: 804275938612470, local_file: uploads/media_6999a3bdb40265.38760593.pdf, local_thumb: null +[2026-02-21 08:34:47] Raw input: {"recipient":"573022548060","media_url":"https://bot.u-s.app/uploads/media_6999b47726c6d2.39335816.png","media_type":"image","caption":null,"filename":"image.png","is_voice":false} +[2026-02-21 08:34:47] Input decoded: {"recipient":"573022548060","media_url":"https:\/\/bot.u-s.app\/uploads\/media_6999b47726c6d2.39335816.png","media_type":"image","caption":null,"filename":"image.png","is_voice":false} +[2026-02-21 08:34:47] is_voice: false +[2026-02-21 08:34:47] Local file: /var/www/html/api/../uploads/media_6999b47726c6d2.39335816.png exists=yes size=959684 +[2026-02-21 08:34:48] Upload result: {"id":"1991468428383665"} +[2026-02-21 08:34:48] Media ID obtained: 1991468428383665 +[2026-02-21 08:34:49] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMEZEOTkyQUI4RDA2REVENEFEAA=="}]} +[2026-02-21 08:34:49] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMEZEOTkyQUI4RDA2REVENEFEAA=="}]} +[2026-02-21 08:34:49] Saving to DB - content: image.png, media_url: 1991468428383665, local_file: uploads/media_6999b47726c6d2.39335816.png, local_thumb: uploads/media_6999b47726c6d2.39335816.png +[2026-02-21 08:40:33] Raw input: {"recipient":"573022548060","media_url":"https://bot.u-s.app/uploads/media_6999b5d189a758.65902454.pdf","media_type":"document","caption":null,"filename":"ACTA 1 U-SITE BIC SAS_1.pdf","is_voice":false} +[2026-02-21 08:40:33] Input decoded: {"recipient":"573022548060","media_url":"https:\/\/bot.u-s.app\/uploads\/media_6999b5d189a758.65902454.pdf","media_type":"document","caption":null,"filename":"ACTA 1 U-SITE BIC SAS_1.pdf","is_voice":false} +[2026-02-21 08:40:33] is_voice: false +[2026-02-21 08:40:33] Local file: /var/www/html/api/../uploads/media_6999b5d189a758.65902454.pdf exists=yes size=139998 +[2026-02-21 08:40:34] Upload result: {"id":"2458076157978363"} +[2026-02-21 08:40:34] Media ID obtained: 2458076157978363 +[2026-02-21 08:40:35] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNkY5MjcxOEJBREQ4Mjk5MzU3AA=="}]} +[2026-02-21 08:40:35] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSNkY5MjcxOEJBREQ4Mjk5MzU3AA=="}]} +[2026-02-21 08:40:35] Saving to DB - content: ACTA 1 U-SITE BIC SAS_1.pdf, media_url: 2458076157978363, local_file: uploads/media_6999b5d189a758.65902454.pdf, local_thumb: null +[2026-02-21 08:40:42] Raw input: {"recipient":"573022548060","media_url":"https://bot.u-s.app/uploads/media_6999b5da753c03.21080157.png","media_type":"image","caption":null,"filename":"image.png","is_voice":false} +[2026-02-21 08:40:42] Input decoded: {"recipient":"573022548060","media_url":"https:\/\/bot.u-s.app\/uploads\/media_6999b5da753c03.21080157.png","media_type":"image","caption":null,"filename":"image.png","is_voice":false} +[2026-02-21 08:40:42] is_voice: false +[2026-02-21 08:40:42] Local file: /var/www/html/api/../uploads/media_6999b5da753c03.21080157.png exists=yes size=959684 +[2026-02-21 08:40:43] Upload result: {"id":"1637119407285011"} +[2026-02-21 08:40:43] Media ID obtained: 1637119407285011 +[2026-02-21 08:40:44] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMjE1MDZGMDAyQ0Q4MTI3OTg5AA=="}]} +[2026-02-21 08:40:44] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSMjE1MDZGMDAyQ0Q4MTI3OTg5AA=="}]} +[2026-02-21 08:40:44] Saving to DB - content: image.png, media_url: 1637119407285011, local_file: uploads/media_6999b5da753c03.21080157.png, local_thumb: uploads/media_6999b5da753c03.21080157.png +[2026-02-21 08:41:52] Raw input: {"recipient":"573022548060","media_url":"https://bot.u-s.app/uploads/media_6999b620bce0e2.99054574.png","media_type":"image","caption":null,"filename":"3 (2).png","is_voice":false} +[2026-02-21 08:41:52] Input decoded: {"recipient":"573022548060","media_url":"https:\/\/bot.u-s.app\/uploads\/media_6999b620bce0e2.99054574.png","media_type":"image","caption":null,"filename":"3 (2).png","is_voice":false} +[2026-02-21 08:41:52] is_voice: false +[2026-02-21 08:41:52] Local file: /var/www/html/api/../uploads/media_6999b620bce0e2.99054574.png exists=yes size=3592731 +[2026-02-21 08:41:54] Upload result: {"id":"2095167437923441"} +[2026-02-21 08:41:54] Media ID obtained: 2095167437923441 +[2026-02-21 08:41:55] Send media by id response: {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSODUxOUM2MzM5RUU4NDE0RjA4AA=="}]} +[2026-02-21 08:41:55] WhatsApp response (successful): {"messaging_product":"whatsapp","contacts":[{"input":"573022548060","wa_id":"573022548060"}],"messages":[{"id":"wamid.HBgMNTczMDIyNTQ4MDYwFQIAERgSODUxOUM2MzM5RUU4NDE0RjA4AA=="}]} +[2026-02-21 08:41:55] Saving to DB - content: 3 (2).png, media_url: 2095167437923441, local_file: uploads/media_6999b620bce0e2.99054574.png, local_thumb: uploads/media_6999b620bce0e2.99054574.png diff --git a/api/version/media-url_debug.log b/api/version/media-url_debug.log index e13441e..5376997 100644 --- a/api/version/media-url_debug.log +++ b/api/version/media-url_debug.log @@ -504,3 +504,59 @@ [2026-02-21 07:35:57] Auto-download failed for media 1217156256734654: Graph API fetch failed: [2026-02-21 07:35:57] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 [2026-02-21 07:35:57] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:34:45] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:34:45] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:34:45] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:34:45] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:34:45] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AjC3mWIMuF1muKdltcuY014"}} +[2026-02-21 08:34:45] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:34:45] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:34:49] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:34:49] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:34:49] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"ApsNyb4eIYG2C5n1FTAy00K"}} +[2026-02-21 08:34:49] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:34:49] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:34:49] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:34:49] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:40:20] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:40:20] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:40:21] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:40:21] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:40:21] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"Ah0dLUuS3QiNrPxl6b41-3W"}} +[2026-02-21 08:40:21] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:40:21] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:40:25] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:40:25] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:40:25] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AZr4Dk_1Q_CuLsg8VdG1b0K"}} +[2026-02-21 08:40:25] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:40:25] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:40:25] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:40:25] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:40:35] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:40:35] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:40:35] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:40:35] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:40:35] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AT-D7BR-K4O34lkBAaR3cUW"}} +[2026-02-21 08:40:35] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:40:35] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:40:44] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:40:44] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:40:44] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:40:44] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:40:44] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AlmJWMomk3u4a1CH4CxEm53"}} +[2026-02-21 08:40:44] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:40:44] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:41:55] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:41:55] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:41:55] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:41:55] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:41:55] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"A-mlaLU25UozpVhAo2dmdqf"}} +[2026-02-21 08:41:55] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:41:55] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 +[2026-02-21 08:43:43] Request: GET /api/version/media-url.php?url=https%3A%2F%2Flookaside.fbsbx.com%2Fwhatsapp_business%2Fattachments%2F%3Fmid%3D2371342336638440%26source%3Dwebhook%26ext%3D1769575796%26hash%3DARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA GET:{"url":"https:\/\/lookaside.fbsbx.com\/whatsapp_business\/attachments\/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA"} POST:[] +[2026-02-21 08:43:43] Request: GET /api/version/media-url.php?id=1217156256734654 GET:{"id":"1217156256734654"} POST:[] +[2026-02-21 08:43:43] Graph API fetch failed for mid 2371342336638440 - http: 400 - err: - resp: {"error":{"message":"Unsupported get request. Object with ID '2371342336638440' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"Aq9eKSgcrutUEDyXpf4mNob"}} +[2026-02-21 08:43:43] Streaming Facebook media with Authorization: https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA +[2026-02-21 08:43:43] Auto-download failed for media 1217156256734654: Graph API fetch failed: +[2026-02-21 08:43:43] Graph API request to https://graph.facebook.com/v22.0/1217156256734654 +[2026-02-21 08:43:43] streamRemoteFile failed: url=https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2371342336638440&source=webhook&ext=1769575796&hash=ARndVKdw1p0CCx3_DpTblR2aOVkb_W5mbTqGFPSOK77cjA err= http=404 diff --git a/classes/MediaService.php b/classes/MediaService.php index 2d51f38..83b80ad 100644 --- a/classes/MediaService.php +++ b/classes/MediaService.php @@ -11,8 +11,13 @@ class MediaService { private $uploadsDir; public function __construct() { - $this->token = getConfigFromDB('whatsapp_token', ''); - $this->apiUrl = rtrim(getConfigFromDB('whatsapp_api_url', 'https://graph.facebook.com/v22.0/'), '/'); + // Usar constante WHATSAPP_TOKEN (que ya tiene fallback a env var) si getConfigFromDB retorna vacío + $dbToken = getConfigFromDB('whatsapp_token', ''); + $this->token = !empty($dbToken) ? $dbToken : (defined('WHATSAPP_TOKEN') ? WHATSAPP_TOKEN : getenv('WHATSAPP_TOKEN')); + + $dbApiUrl = getConfigFromDB('whatsapp_api_url', ''); + $this->apiUrl = rtrim(!empty($dbApiUrl) ? $dbApiUrl : (defined('WHATSAPP_API_URL') ? WHATSAPP_API_URL : 'https://graph.facebook.com/v22.0/'), '/'); + $this->uploadsDir = __DIR__ . '/../uploads/media'; if (!is_dir($this->uploadsDir)) mkdir($this->uploadsDir, 0755, true); } diff --git a/config/config.php b/config/config.php index 45028b0..32ed640 100644 --- a/config/config.php +++ b/config/config.php @@ -667,15 +667,31 @@ function saveWhatsAppConfigToDB($whatsappConfig) { * @return array Configuración completa de WhatsApp */ function getWhatsAppConfigFromDB() { + // Usar constantes como fallback (ya tienen cascada BD > env > default) + $token = getConfigFromDB('whatsapp_token', ''); + if (empty($token) && defined('WHATSAPP_TOKEN')) $token = WHATSAPP_TOKEN; + if (empty($token)) $token = getenv('WHATSAPP_TOKEN') ?: ''; + + $phoneId = getConfigFromDB('whatsapp_phone_number_id', ''); + if (empty($phoneId) && defined('WHATSAPP_PHONE_NUMBER_ID')) $phoneId = WHATSAPP_PHONE_NUMBER_ID; + if (empty($phoneId)) $phoneId = getenv('WHATSAPP_PHONE_NUMBER_ID') ?: ''; + + $apiUrl = getConfigFromDB('whatsapp_api_url', ''); + if (empty($apiUrl) && defined('WHATSAPP_API_URL')) $apiUrl = WHATSAPP_API_URL; + if (empty($apiUrl)) $apiUrl = 'https://graph.facebook.com/v22.0/'; + + $webhookToken = getConfigFromDB('webhook_verify_token', ''); + if (empty($webhookToken) && defined('WEBHOOK_VERIFY_TOKEN')) $webhookToken = WEBHOOK_VERIFY_TOKEN; + return [ // Mapear a nombres esperados por el código - 'token' => getConfigFromDB('whatsapp_token', ''), - 'whatsapp_token' => getConfigFromDB('whatsapp_token', ''), - 'phone_number_id' => getConfigFromDB('whatsapp_phone_number_id', ''), + 'token' => $token, + 'whatsapp_token' => $token, + 'phone_number_id' => $phoneId, 'business_account_id' => getConfigFromDB('whatsapp_business_account_id', ''), - 'api_url' => getConfigFromDB('whatsapp_api_url', 'https://graph.facebook.com/v22.0/'), - 'whatsapp_api_url' => getConfigFromDB('whatsapp_api_url', 'https://graph.facebook.com/v22.0/'), - 'webhook_verify_token' => getConfigFromDB('webhook_verify_token', ''), + 'api_url' => $apiUrl, + 'whatsapp_api_url' => $apiUrl, + 'webhook_verify_token' => $webhookToken, 'business_name' => getConfigFromDB('business_name', ''), 'welcome_message' => getConfigFromDB('welcome_message', ''), 'status' => validateWhatsAppConfigFromDB() diff --git a/logs/system.log b/logs/system.log index d1f4bad..d8bcb07 100755 --- a/logs/system.log +++ b/logs/system.log @@ -231,3 +231,4 @@ Stack trace: [2026-02-03 16:19:48] [INFO] Mensaje programado creado: ID=7, Usuario=3277, Fecha=2026-02-03 16:20 [2026-02-03 20:47:36] [INFO] Mensaje programado creado: ID=8, Usuario=3250, Fecha=2026-02-03 20:48 [2026-02-03 20:54:33] [INFO] Mensaje programado creado: ID=9, Usuario=3250, Fecha=2026-02-03 20:55 +[2026-02-06 10:23:52] [INFO] Cleared advisor_requested for user 3250 after outgoing message by operator diff --git a/services/WhatsAppService.php b/services/WhatsAppService.php index 48bf240..5987231 100644 --- a/services/WhatsAppService.php +++ b/services/WhatsAppService.php @@ -452,10 +452,19 @@ class WhatsAppService $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $curlError = curl_error($ch); + $curlErrno = curl_errno($ch); curl_close($ch); + // Log detallado para diagnóstico + error_log("WhatsAppService::uploadMedia - URL: {$url}, HTTP: {$httpCode}, curlErrno: {$curlErrno}, curlError: {$curlError}, tokenLen: " . strlen($this->token) . ", phoneId: {$this->phoneNumberId}"); + + if ($curlErrno !== 0) { + throw new Exception("Error de conexión subiendo archivo (curl #{$curlErrno}): {$curlError}"); + } + if ($httpCode !== 200 && $httpCode !== 201) { - throw new Exception("Error subiendo archivo: " . $response); + throw new Exception("Error subiendo archivo (HTTP {$httpCode}): " . $response); } $result = json_decode($response, true);