Skip to content

Instantly share code, notes, and snippets.

View shatsar's full-sized avatar
🌵

Michele Zonca shatsar

🌵
View GitHub Profile
@shatsar
shatsar / gemfile
Created September 8, 2011 17:51
mashape ruby library Gemfile
source :rubygems
gem "json"
gem "uuid"
gem "ruby-hmac"
@shatsar
shatsar / gist:1301412
Created October 20, 2011 15:21 — forked from subnetmarco/gist:1300184
XML v4
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://mashape.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://mashape.com mashape-4.0.xsd ">
<authentication type="header">
<description><![CDATA[This is a simple header authentication]]></description>
<parameters>
<parameter name="X-Pippo-Username" optional="false">
<description><![CDATA[Please enter here your username]]></description>
</parameter>
<parameter name="X-Pippo-Password" optional="false">
@shatsar
shatsar / sample.java
Created November 16, 2011 01:19
Generated Java Client Library
import Bitly;
[..]
// and when you are ready to use it just create a new instance!
Bitly client = new Bitly("MY_PUBLIC_KEY", "MY_PRIVATE_KEY");
@shatsar
shatsar / sample2.java
Created November 16, 2011 01:27
Usage of Mashape Java Client Library
Bitly client = new Bitly("MY_PUBLIC_KEY", "MY_PRIVATE_KEY");
JSONObject result = client.getShortenedUrl(originalUrl, login, apikey);
@shatsar
shatsar / sample.py
Created November 16, 2011 01:31
Generated Python Client Library
from Bitly import Bitly
obj = Bitly("MY_PUBLIC_KEY", "MY_PRIVATE_KEY")
@shatsar
shatsar / async.py
Created November 16, 2011 04:22
Python asynchronous mode
from Bitly import Bitly
obj = Bitly("MY_PUBLIC_KEY", "MY_PRIVATE_KEY")
def my_function(result):
print result
obj.getShortenedUrl("http://mashape.com", "mashape", "apikey", my_function)
print "waiting"
@shatsar
shatsar / sample.rb
Created November 16, 2011 04:24
Generated Ruby Client Library
require "Bitly.rb"
obj = Bitly.new("MY_PUBLIC_KEY", "MY_PRIVATE_KEY")
#import "Sample.h"
@implementation Sample
- (void) doAPIRequest {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@try {
// Initialize the Obj-C Client Library with a Developer key
// ...
// Call a method asynchronously and get a Thread object
Thread thread = bitly.getShortenedUrl("http://www.mashape.com", "bitly-login", "bitly-api-key", new MashapeCallback() {
@Override
public void requestCompleted(Object response) {
JSONObject jsonResponse = (JSONObject) response;
System.out.println("Finally the shortened url is " + jsonResponse.getString("shortenedUrl"));
}
# ...
# Call a method asynchronously and get a Thread object
thread = bitly.getShortenedUrl("http://www.mashape.com", "bitly-login", "bitly-api-key") { |response|
shortenedUrl = response["shortenedUrl"] # See the API's documentation
puts "Finally the shortened url is " + shortenedUrl
}
=begin