Skip to content

Instantly share code, notes, and snippets.

@YungSang
Created December 10, 2010 00:31
Show Gist options
  • Save YungSang/735571 to your computer and use it in GitHub Desktop.
Save YungSang/735571 to your computer and use it in GitHub Desktop.
[Deprecated] Pipio Plugin for Cortex
function Pipio() {
this.background = '#ffffff';
}
Pipio.prototype = new Service('Pipio');
Pipio.prototype.constructor = function() {
};
Pipio.prototype.authenticate = function(username, password, success, error) {
success();
};
Pipio.prototype.isConnected = function() {
return true;
};
Pipio.prototype.post = function(options) {
var url = 'http://pip.io/api/posts/post/create?';
var query = [];
var attachments = 'attachments=[';
attachments += '{%22type%22:2,%22url%22:%22' + encodeURIComponent(options.link) + '%22}';
if (options.type == 'image') {
attachments += ',{%22type%22:2,%22url%22:%22' + encodeURIComponent(options.image) + '%22}';
}
attachments += ']';
query.push(attachments);
var body = 'body=';
body += encodeURIComponent(options.title);
if (options.message !== undefined) {
body += "%0D%0A" + encodeURIComponent(options.message);
}
if (options.text !== undefined) {
body += "%0D%0A\"" + encodeURIComponent(options.text) + "\"";
}
query.push(body);
$.getJSON(url + query.join('&') + '&targets=&channels=&cc=&cc_data=&source_id=0&source_type=1&is_public=1&reply_id=0',
function(data) {
options.success('http://pip.io/#/user/' + data.data.post.creator.username + '/convo/' + data.data.post.post_id);
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment