lior I 0 Posted December 1, 2022 Hello. I need to send a PDF file to a WhatsApp recipient using WhatsApp Cloud API. Can someone help me translate this WhatsApp sample curl code to Delphi pascal? Here is the code from the WhatsApp documentation: Step1: Upload media to cloud API. curl -X POST \ 'https://graph.facebook.com/v15.0/FROM_PHONE_NUMBER_ID/media' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -F 'file=@/local/path/file.jpg;type=image/jpeg' -F 'messaging_product=whatsapp' A successful response includes an object with an identifier for the media: { "id":"ID" } Step 2: Send message using media ID. curl -X POST \ 'https://graph.facebook.com/v15.0/FROM-PHONE-NUMBER-ID/messages' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "messaging_product": "whatsapp", "recipient_type": "individual", "to": "PHONE-NUMBER", "type": "image", "image": { "id" : "MEDIA-OBJECT-ID" } }' I’m using Delphi RIO 10.3 Thank you in advance Share this post Link to post
programmerdelphi2k 237 Posted December 1, 2022 (edited) wrong subject... sorry! Edited December 1, 2022 by programmerdelphi2k Share this post Link to post
lior I 0 Posted December 2, 2022 What's the problem with the title? I need to send a file to a WhatsApp recipient using the WhatsApp cloud. The documentation explains sending a JPG file and not a PDF file like I want, but that will be enough for me to move on. Share this post Link to post
programmerdelphi2k 237 Posted December 2, 2022 3 hours ago, lior I said: The documentation explains sending a JPG file JPG or PDF it's all bits to computer, then, what the difference to Whapsapp? Share this post Link to post
lior I 0 Posted December 3, 2022 (edited) I agree. Almost identical code for sending both types of files. Edited December 4, 2022 by lior I Share this post Link to post
programmerdelphi2k 237 Posted December 4, 2022 I believe that you have 2 problems now: 1) send a file by Whatsapp; 2) your glasses is broken Share this post Link to post
lior I 0 Posted December 4, 2022 (edited) Ok. Reduced font size Edited December 4, 2022 by lior I Share this post Link to post
lior I 0 Posted December 14, 2022 Quote curl -X POST \ 'https://graph.facebook.com/v15.0/FROM_PHONE_NUMBER_ID/media' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -F 'file=@/local/path/file.jpg;type=image/jpeg' -F 'messaging_product=whatsapp' I don't know how to translate the file parameter. -F 'file=@/local/path/file.jpg;type=image/jpeg' It includes both path and file type attributes. Share this post Link to post
Lajos Juhász 293 Posted December 14, 2022 You have to replace /local/path/file.jpg with your pdf file and type=application/pdf. Share this post Link to post