Glad you showed us everything you tried. You are really close, man!
go to Setup > Remote Site Settings and create an entry for http://www.woopra.com/
create the following Visualforce Page and Apex Class, then view the page at /apex/Woopra
see if you get a 403 like I do ;-) then substitute your real credentials into the request headers
play until it gives you 200 OK, then remove the System.assert...
(that was for debug)
eyeball the response data, and how you might go about parsing / displaying it...
Don't forget to update us!
Here's how you might do your API call in Apex - try:
WoopraController.cls
public class WoopraController {
public String Headers {get; set;}
public String Response {get; set;}
public void doRequest() {
String data = '{'
+ '\n' + '"website":"yourwebsite",'
+ '\n' + '"segment":['
+ '\n' + ' {'
+ '\n' + ' "did":{'
+ '\n' + ' "operator":"AND",'
+ '\n' + ' "filters":['
+ '\n' + ' {'
+ '\n' + ' "scope":"actions",'
+ '\n' + ' "key":"name",'
+ '\n' + ' "match":"match",'
+ '\n' + ' "value":"quote"'
+ '\n' + ' }'
+ '\n' + ' ]'
+ '\n' + ' },'
+ '\n' + ' "are":{'
+ '\n' + ' "operator":"AND",'
+ '\n' + ' "filters":[]'
+ '\n' + ' }'
+ '\n' + ' }'
+ '\n' + '],'
+ '\n' + '"offset":0,'
+ '\n' + '"report_id":-1' +
'}';
System.HttpRequest request = new System.HttpRequest();
request.setBody(data);
request.setMethod('POST');
request.setEndpoint('http://www.woopra.com/rest/search');
request.setHeader('X-Api-Version', '2.0');
request.setHeader('X-Access-Id', 'APP_IDXXXXXXXX');
request.setHeader('X-Access-Secret', 'SECRET_KEYXXXXXXX');
System.HttpResponse response = new System.Http().send(request);
System.assert(false, response); //remove this once you fix the 403
this.Response = response.getBody();
}
}
Woopra.page
<apex:page controller="WoopraController" action="{!doRequest}" contentType="text/plain">
{!Headers}
{!Response}
</apex:page>
Best Answer
You normally have to do this at the client end, e.g. in your code, by parsing the HTML and then using the W3C DOM method getTextContent on the root node (for example).
However in reviewing the documentation on Rich Text fields, it seems that if you reference the field in a Formula the HTML markup is stripped out.
You cannot directly reference a Rich Text field in a regular Formula Field, however you can reference it, in addition to validation rules, in a Workflow Field Update. In the example below I created a "Rich Text" field (Rich Text type) and "Rich Text Text" field (regular Text Area type). Then I create a Workflow and Workflow Field Update to update the Rich Text Text field each time the user changed the Rich Text field.
With something like this in place you can query for the text only version in your REST request. The following shows my Workflow definition if you need to understand this further.