How to test Woocommerce webhooks in java - java

I am working on ecommerce application which is having backend written in java programming langauge.
Application is having code to listen Woocommerce Webhook events. I logged in Woocommerce site and check Webhook configuration and logs in Woocomerce->Status->logs. Logs are showing 200 status code in response. So, no problem I can see in Woocommerce webhook but my application is not listening any webhook events like order.created, etc.
What I was thinking to test it with any example java source code sothat I can get where is problem.
So, if anyone is having good java source code to test Woocommerce Webhook, Please suggest. If anyone face this problem ever, please share.

Not sure that you are fully aware of what WOO-Webhooks are intended to do.
Basically is send some post data to a specific link and from there it's up to you to do whatever wanted with data.
A simple receiverwith php can be (that you specified at Delivery URL)
<?php
//echo date("l jS \of F Y h:i:s A");
$msg = "woo order \n";
if($_SERVER['REQUEST_METHOD']=="POST")
{
$data = file_get_contents('php://input');
$msg .= strval($data);
}
// send email
mail("yourmail#mail.com","woo order",strval($msg));
//echo date("l jS \of F Y h:i:s A");
Response on mail can be something like:
Instead of processing, data is dumped to mail. It's up to you here to implement any logic since you got the data.
If wanted to process something with another language java then adapt it (do a web-server, externalize the link, process as suitable the data). Same steps as example provided.
On Logs can be found addition information about what was delivered, how ...

Related

Why am I not able to read the complete email body using Exchange Web Service Java API?

I am using EWS Java API to read and process emails. One such email contains few conversation and a MS Teams meeting information at the end. While reading such an email, the EmailMessage.getBody() returns only the MS Teams meeting information and all the other contents of the email body are ommitted. Sample code below:
EmailMessage message = EmailMessage.bind(service, new ItemId(item.get(nMessagePos).getId().getUniqueId()));
String emailBody = message.getBody().toString()
I tried setting the BodyType property to both HTML and Text and then fetched the body of the email but it still returns only the Meeting invite details.
Is there any specific reason for this and is there a way for me to get the complete email body?
I would try to enable tracing https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-trace-requests-responses-to-troubleshoot-ews-managed-api-applications or look at the actually soap responses your getting it could be a parsing issue at the client side (eg bug in the library). You could also try getting the Mimecontent of the Message instead and then parse back the body from that content. Something like EWSEditor might be useful for trying to diagnose what is going on it will show you what the responses look like and allow you to test mimecontent etc without needing to write any code https://github.com/dseph/EwsEditor/releases.

AEM Human Translation Getting The Response From Server?

I use bootstrap translation framework (Git : https://forums.adobe.com/external-link.jspa?url=https%3A%2F%2Fgithub.com%2FAdobe-Marketing-Cloud%2Faem-translation-framework-bootstrap-connector%2Fblob%2Fmaster%2Fbundle%2Fsrc%2Fmain%2Fjava%2Fcom%2Fadobe%2Fgranite%2Ftranslation%2Fconnector%2Fbootstrap%2Fcore%2Fimpl%2FBootstrapTranslationServiceImpl.java) : I use this method uploadTranslationObject for posting to my server and one request is completed.
I just have a small doubt like i use human translation the response will be coming after some X delay time.Now i am wondering how do i get the response once the translated response is ready from my server??
I have the logic of returning the translated xml on my server but question is how do i return it?? I mean where should my server post on some api or will ame keeps constantly looking for the response?
Can someone please let me know with a small code or a existing method? I need to find in which method of the code will the response from server will be handled ??
Thanks In Advance.
You will have to monitor the status of the Documents(TranslationObjects). When you upload the TO for translation via uploadTranslationObject() change the status of the TO to 'SUBMITTED' or 'TRANSLATION_IN_PROGRESS'.
Then in the getTranslationObjectStatus() you will make request to your server to know if the TO are translated or not. If the TO is translated then you can change the status of the TO to 'TRANSLATED'. The method getTranslationObjectStatus() will return TranslationStatus as TRANSLATED, this will invoke getTranslatedObject() where you will download the translated TO and return it as InputStream.
Note: getTranslationObjectStatus() and other status update helper methods will be called when you refresh the TranslationJob Page.

Sending embedded survey email using MonkeySurvey API

What should be the body-text or body-html when doing a POST request using this API to create messages?
API - https://developer.surveymonkey.com/api/v3/#collectors-id-messages
When I am inserting survey link in the body, I am not getting a clickable embedded question in the mail body like we get when using email collector from console.
Building that format is not currently supported in the API, you can only create with a custom HTML.
That said you can copy a previous message that is in the right format through the API. From the link you specified: https://developer.surveymonkey.com/api/v3/#collectors-id-messages
It shows you can set a from collector/message to copy:
POST /v3/collectors/<collector_id>/messages
{
"from_collector_id": "<any_collector_id>",
"from_message_id": "<message_id_from_provided_collector_id>"
}
That will take a copy of a message you already have created as a template and create a new message. Hopefully that could be a good workaround for your use case.

How to get SMTP-ID in sendgrid API through json?

How to get SMTP-ID in sendgrid API through json? Example :
In the API tutorial they have mentioned to execute
http(s)://username:password#domain/foo.php
and the result will be (in json):
"email": "john.doe#sendgrid.com",
"timestamp": 1337197600,
"smtp-id": "<4FB4041F.6080505#sendgrid.com>",
"event": "processed"
But actually we need the perfect url to get json.
for eg :
https://sendgrid.com/api/bounces.get.json
for bounce mails
similarly , is there anything to get the above sample json.
Thanks in advance..
If you send an Email to SendGrid through the Web API, you won't have an SMTP-ID. That will be generated by the SendGrid server that translates the API call to an SMTP object. So you're right, the SMTP-ID that comes back in the Event POST isn't helpful.
However, you can add Unique Args to your API call using the x-smtpapi argument in the mail.send call. This will let you define whatever tracking metric(s) you want to the message, and it will all come back on the Event POST.
If you are going to use Unique Args feature, please do remember that they will appear in the most Event notifications but not all of them. Please refer for the details to the sendgrid forum topics which include "missing unique_args" and similar. So, think twice before "building the entire infrastructure" around this feature like some of us did :(
I got my answer .
Actually we can try event API using a callback url, that receives POST request having every details about the email delivered, bounced in json format. Whenever some event is triggered we get a request from Sendgrid. Thats cool.
We can keep these details for further Filtering.
Anyway , thanks jacobmovingfwd

Handle request from external website

I'm writing an application that sends requests to the Twitter API. One part of the flow requires a redirect to the Twitter login page. After the user has logged in, a request is sent back to the callback url with information I need to continue the flow. The thing is, after logging in, my application pops up with the relevant information in the url bar. So, for example the url would look like this:
{http://localhost:9000/?oauth_token=KlQrT7YoFC2j3wAVGK57JRRI5h6LFI08H1zkhm8uEo&oauth_verifier=dU1H8D1no1wmKNRdpecHDrWegTQm4dvI15rnUblqxM}
I need the information after the {'http://localhost:9000'} so my question is, how do I get that?
The only information I can find on HTTP Request is making them, very little about receiving them. And even the stuff I did find on receiving them doesn't cover the issue I'm having. I imagine a solution to this problem could be very useful seeing as it goes to the core of any application that wants to implement sign in with Twitter.
Any help would be greatly appreciated.
Create a controller which serves /, example routes file
GET / Twitter.authorize
And then in the controller you can use the parameters:
public static void authorize(String oauth_token, String oauth_verifier) {
.... do something ....
}

Categories