This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Jambase4Net; | |
public class App | |
{ | |
public static void Main(String[] args) | |
{ | |
//You can use the default configuration, which reads from app.config or web.config | |
//To do this, just start using the API object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Using JamBase4R in Rails is simple. Just include it in the controller you want to use | |
class MyJamBaseController < ApplicationController | |
include JamBase4R | |
def search | |
@results = API.search(params[:search]) | |
#You could also NOT include JamBase4R and just call it like so: | |
# @results = JamBase4R::API.search(params[:search]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#For Rails: | |
#in an initializer | |
JamBase4R.configure do |c| | |
c.api_key = "your JamBase API key" #this is mandatory | |
c.logger = RAILS_DEFAULT_LOGGER #or any class that implements the same interface (optional) | |
end | |
#For Sinatra | |
#within the main application file | |
configure do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is a Gist. This is also how you embed the Gist | |
<script src="http://gist.github.com/98216.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#To announce an article: | |
RDefensio::API.announce_article({ | |
"article-author" => "Me", | |
"article-author-email" => "[email protected]", | |
"article-title" => @post.title, | |
"article-content" => @post.body, | |
"permalink" => @post.slug | |
} | |
#To audit a comment: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configure do | |
RDefensio::API.configure do |conf| | |
conf.api_key = App::Config.defensio_api_key | |
conf.owner_url = App::Config.defensio_owner_url | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_bar_chart(opts, data) | |
g = Gruff::Bar.new(opts[:size]) | |
g.title = opts[:title] | |
g.minimum_value = opts[:minimum] | |
g.maximum_value = opts[:maximum] | |
g.labels = data.map { |e| e.category } | |
g.data(opts[:legend], data.map { |e| e.count } ) | |
g.x_axis_label = opts[:x_axis_label] | |
g.y_axis_label = opts[:y_axis_label] | |
return g.to_blob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSONArray objects = new JSONArray(response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. private String get(String url, Map params) | |
2. { | |
3. String result = null; | |
4. try | |
5. { | |
6. String queryString = getEncodedQueryString(params); | |
7. String fullUrl = url + "?" + queryString; | |
8. DefaultHttpClient client = new DefaultHttpClient(); | |
9. HttpGet method = new HttpGet(new URI(fullUrl)); | |
10. HttpResponse response = client.execute(method); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. private List parseComplaints(String results) | |
2. { | |
3. List complaints = new ArrayList(); | |
4. try | |
5. { | |
6. JSONArray objects = new JSONArray(results); | |
7. for(int i=0; i<objects.length(); i++) | |
8. { | |
9. JSONObject o = (JSONObject)objects.get(i); | |
10. Complaint c = new Complaint(); |