-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to debug request and response header #82
Comments
Hello and welcome! We're glad to see that you've opened your first issue. We appreciate your contribution and would love to hear more about the problem you're experiencing. Our team is actively monitoring this repository and we will do our best to respond to your issue as soon as possible. Thank you for using our project and we look forward to working with you! |
Hello @tmoreira2020 , I'm glad that you're using this SDK. I'm looking for a way to create a log for API requests. If you have any suggestions, I would appreciate it. Regarding image sending, here's a brief tutorial:
WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN);
WhatsappBusinessCloudApi whatsappBusinessCloudApi = factory.newBusinessCloudApi();
var fileName = "starwars.png";
// reading the image
byte[] fileContent = Files.readAllBytes(Paths.get("src/test/resources/" + fileName));
//uploading to whatsapp api
var uploadResponse = whatsappBusinessCloudApi.uploadMedia(PHONE_NUMBER_ID, fileName, FileType.PNG, fileContent);
System.out.println(uploadResponse);
//sending the message with the image id returned after upload
var imageMessage = new ImageMessage()//
.setId(uploadResponse.id())// media id (uploaded before)
.setCaption("See this image, please");
var message = MessageBuilder.builder()//
.setTo(PHONE_NUMBER_1)//
.buildImageMessage(imageMessage);
MessageResponse messageResponse = whatsappBusinessCloudApi.sendMessage(PHONE_NUMBER_ID, message);
System.out.println(messageResponse);
WhatsappApiFactory factory = WhatsappApiFactory.newInstance(TOKEN);
WhatsappBusinessCloudApi whatsappBusinessCloudApi = factory.newBusinessCloudApi();
var imageMessage = new ImageMessage()//
.setLink("https://upload.wikimedia.org/wikipedia/pt/4/45/Yoda.jpg").setCaption("See this image, please");
var message = MessageBuilder.builder()//
.setTo(PHONE_NUMBER_1)//
.buildImageMessage(imageMessage);
MessageResponse messageResponse = whatsappBusinessCloudApi.sendMessage(PHONE_NUMBER_ID, message);
System.out.println(messageResponse);
See also media object and Media If you have any questions, please comment on this issue. |
Hey Maurício, first of all congrats in building such easy to use API. I've been looking for it for years! 😄
I'm still on testing phase and one things that I'm having hard time it to send ImageMessages to my phone number using the test number provided by Facebook. I will figured out what is going on but it will be much easier if I could turn on and off debug modes.
I have it working locally in a hackie way, once I have time I will send you a PR with the required changes.
Obrigado
The text was updated successfully, but these errors were encountered: