Determining the URL for an interface

Occasionally you need to determine the domain name for an interface in RightNow CX. There are many ways in which we can retrieve the interface names (using an OptList in the Add-In Framework, or the getValuesForNamedID() method in the SOAP or PHP Connect APIs). And from the interface name you can typically determine the domain name.

For instance, if your interface name is "foo_bar", your domain name would be "foo-bar.custhelp.com". Note that certain characters (such as an underscore) are translated to a dash in the domain name. You will need to build this logic into your application. I don't know all of the rules, but likely any character outside of a-z & 0-9 should be replaced with a dash.

This is fine unless the interface is using a vanity URL (custom CNAME), such as "support.foobar.com". However, you can still get the vanity URL for the interface. This article will show you how.

RightNow does create DNS entries for a custhelp.com sub-domain for all interfaces, even those with a vanity URL. When an interface has a vanity URL, any request to the custhelp.com sub-domain will automatically be redirected with an HTTP 301 response. Here is an example of what this looks like using the cURL command line utility:

user@host]$ curl -v http://foo-bar.custhelp.com/cgi-bin/foo_bar.cfg/services/soap?wsdl=typed
* About to connect() to foo-bar.custhelp.com port 80 (#0)
*   Trying 216.136.229.202...
* connected
* Connected to foo-bar.custhelp.com (216.136.229.202) port 80 (#0)
> GET /cgi-bin/foo_bar.cfg/services/soap?wsdl=typed HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8y zlib/1.2.5
> Host: foo-bar.custhelp.com
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Date: Fri, 23 May 2014 23:43:37 GMT
< Server: Apache
< Location: http://support.foobar.com/cgi-bin/foo_bar.cfg/services/soap?wsdl=typed
< Vary: Accept-Encoding
< Content-Length: 276
< Content-Type: text/html; charset=iso-8859-1
< 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://support.foobar.com/cgi-bin/foo_bar.cfg/services/soap?wsdl=typed">here</a>.</p>
</body></html>
* Connection #0 to host foo-bar.custhelp.com left intact
* Closing connection #0

Note that I changed the interface name and domain name in the output above. The hostname foo-bar.custhelp.com is not valid as far as I know.

Notice how the response headers include the 301 status code: "HTTP/1.1 301 Moved Permanently" and the redirect to the vanity URL: "Location: http://support.foobar.com/cgi-bin/foo_bar.cfg/services/soap?wsdl=typed"

So, if you have the interface name you can transform it into the custhelp.com sub-domain, and then make a request to that new domain. Capture the HTTP response headers and from those headers you can determine if there is a vanity URL (if it returns an HTTP 301 status code) and if so, what the vanity URL/domain is (from the Location response header).

Zircon - This is a contributing Drupal Theme
Design by WeebPal.