Watson Customer Engagement for Developers is here!

We have several offerings spanning Marketing and Commerce and many more coming this year. As a developer, you can now sign up to be notified when products and API’s become available on the IBM marketplace. Bookmark it and sign up today for notifications.

Check it out today.

Trilibis PSD to HTML converter

screen-shot-2017-01-18-at-7-56-41-pm

In this segment of Partner Connect I demonstrate how the Trilibis PSD2HTML API is used to create responsive HTML from three versions of the same PSD. The new Triblibis API can take a Web, Mobile, and Tablet version of the design along with a configuration file to identify HTML elements at a very granular level.  Watch this video to see the new API in action.

 

Node-RED : IBM developerWorks Open Tech Talk

Readers of my blog know I am a huge fan of Node-RED so now you can learn about it in the upcoming tech talk by IBM developerWorks. I most recently used Node-RED in an Eclipse application where I provide an automatic translation service for a tool called PET.

node-redIBM developerWorks Open Tech Talk
Node-RED
Categories: Cloud, Internet of Things

Wed June 22nd, 11 AM ET

Web Meeting link.

Node-RED is a tool for wiring together the Internet of Things in new and interesting ways, including hardware devices, APIs, and online services. Node-RED makes it easy to wire together real-world events, add in some intelligence, and access simple nodes to integrate them with existing messaging systems and social platforms such as Twitter, MongoDB, and Redis to create apps that can react to the world around them..  Learn more.

Enabling CORS for WebSphere Commerce REST

Commerce-CORSI have two servers, one application server (JSP based) and one WebSphere Commerce server. I want to be able to call the REST API’s on the Commerce server via JavaScript served up by the application server. So my JavaScript would look like this:

$.ajax({
      url: myCommerceServerRestURL,
      method: "GET",
      crossDomain: true,
      contentType: "application/json",
      dataType: "json"
 })

The problem is, if CORS is not enabled on the WebSphere Commerce server you will receive the infamous No ‘Access-Control-Allow-Origin’ header is present on the requested resource. And the call fails.

Now WebSphere Commerce can be a little tricky if your server has a web server in front of it. You essentially have to enable it in both places – or at least that is what I had to do. If I only had to do one of these please let me know – I got tired of testing the different tips from the netverse.

I have IHS in front of WebSphere Commerce, so, after hours of playing around with different configurations I came up with these steps:

First configure httpd.conf in the IHS/conf directory and add these lines  if you want all domains to be able to access your data:

 <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
        Header set Access-Control-Allow-Methods "GET, PUT, OPTIONS"
        Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
 </IfModule>

Remember, you can always override the Access-Control-Origin with a domain or multiple domains to prevent access for everyone.

Next, you have to update the WebSphere Commerce server. You can actually see the Commerce Insights enabling documentation for this (my colleague pointed me to this, thanks J).  You will be editing the WC configuration file and the WC Search configuration file.

 <_config:configgrouping name="HttpSecuritySettings_Rest">
          <_config:property name="CORSAccessControlAllowOrigin" value="*"/>
          <_config:property name="CORSAccessControlAllowMethods" value="GET, HEAD, POST, OPTIONS, PUT, DELETE"/>
          <_config:property name="CORSAccessControlAllowCredentials" value="true"/>
          <_config:property name="CORSAccessControlAllowHeaders" value="Origin,X-Requested-With,Content-Type,Accept,Authorization,cache-control,expires,pragma,wclogonid,wctoken,wctrustedtoken,wcuserid,X-RequestId"/>
          <_config:property name="CORSAccessControlExposeHeaders" value="Access-Control-Allow-Headers"/>
          <_config:property name="CORSAccessControlMaxAge" value="3600"/> 
 </_config:configgrouping>

 

If you found this useful follow this site! I also have a YouTube channel for IBM Commerce.

Using Watson Translation service in an Eclipse SWT application Part 2

The next follow-up to the last article is the code I used to communicate with the Watson Translation service. But first I want to show the flow of the data:

So basically the SWT client sends a JSON string to the server in the body of the message. You can do this as long as you specify application/json as the Content-Type. For JSON, I use the JSON library for Java over at json.org and its been perfect. I have even begun using this library for all of my in memory objects because then I can easily serialize it out for storage or over the network.

Below you will see the primary code to send this message:

JSONObject payload = new JSONObject();
                	
payload.put("toLang", obj.get("to"));
payload.put("text", obj.get("text"));
                	                	
URL url = new URL(pet_bluemix_translation_service);
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
out.write(payload.toString());
out.close();
                         
//Now get the response
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                	
String n = in.readLine();
StringBuffer sbValue = new StringBuffer();
                	
while(n != null){
	sbValue.append(n);
	n = in.readLine();
}
in.close();
                	
final String value = sbValue.toString();

Using Watson Translation service in an Eclipse SWT application

Image (3) flow-680x156.png for post 5379

In this video I show how I used Watson Translation services in IBM Bluemix to translate an entire catalog of products and categories. I used a simple Node-Red flow to achieve this with little programming on the server-side.

Image optimization delivery with Trilibis SNOW IO

multiple-devices-snow-io

Optimized image delivery has been around for a long time and one open source technology that has provided this to thousands of sites in WordPress is ImageMagick. I have been a huge fan of ImageMagick because it’s so darn simple and straightforward.

Trilibis, a certified IBM Commerce partner has a WebSphere Commerce extension (SNOW IO) that brings image optimization delivery to this extensible platform. The way it works is you install the ImageMagick software on your server and configure it to point to where your images are stored on the server. You then configure a job to run frequently (hourly, daily, weekly) to resize images stored in that directory. The default setup will create three versions of your images – Desktop, Tablet, and Phone sized images.

Check out my video below where I show how I configured SNOW IO to work with the out of the box Aurora starter store in WebSphere Commerce.