Revert "1.2 json support"

This reverts commit 98f028af70.
This commit is contained in:
Brian Antonelli
2011-12-06 21:07:44 -05:00
parent 98f028af70
commit 35587791b1
4 changed files with 46 additions and 17 deletions

View File

@@ -17,28 +17,25 @@ TwitterDemo = {
},
setup:function(){
var tests = ["isAvailable", "isSetup", "tweet", "compose", "timeline", "mentions"];
var tests = ["isAvailable", "isSetup", "tweet", "timeline", "mentions"];
for(var i=0, l=tests.length; i<l; i++){
this.$(tests[i]).onclick = this[tests[i]];
}
},
isAvailable:function(){
TwitterDemo.log("wait..");
window.plugins.twitter.isTwitterAvailable(function(r){
TwitterDemo.log("twitter available? " + r);
});
},
isSetup:function(){
TwitterDemo.log("wait..");
window.plugins.twitter.isTwitterSetup(function(r){
TwitterDemo.log("twitter configured? " + r);
});
},
tweet:function(){
TwitterDemo.log("wait..");
window.plugins.twitter.sendTweet(
function(s){ TwitterDemo.log("tweet success"); },
function(e){ TwitterDemo.log("tweet failure: " + e); },
@@ -48,19 +45,16 @@ TwitterDemo = {
},
compose: function() {
TwitterDemo.log("wait..");
window.plugins.twitter.composeTweet();
},
timeline:function(){
TwitterDemo.log("wait..");
window.plugins.twitter.getPublicTimeline(
function(s){ TwitterDemo.log("timeline success: " + JSON.stringify(s)); },
function(e){ TwitterDemo.log("timeline failure: " + e); });
},
mentions:function(){
TwitterDemo.log("wait..");
window.plugins.twitter.getMentions(
function(s){ TwitterDemo.log("mentions success: " + JSON.stringify(s)); },
function(e){ TwitterDemo.log("mentions failure: " + e); });

View File

@@ -7,7 +7,7 @@
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
<script type="text/javascript" charset="utf-8" src="TwitterPlugin.js"></script>
<script type="text/javascript" charset="utf-8" src="demo.js"></script>
</head>

View File

@@ -7,9 +7,9 @@
#import "TwitterPlugin.h"
#ifdef PHONEGAP_FRAMEWORK
#import <PhoneGap/JSONKit.h>
#import <PhoneGap/JSON.h>
#else
#import "JSONKit.h"
#import "JSON.h"
#endif
#define TWITTER_URL @"http://api.twitter.com/1/"
@@ -94,12 +94,14 @@
}
- (void) composeTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{
TWTweetComposeViewController *tweetComposeViewController = [[TWTweetComposeViewController alloc] init];
[tweetComposeViewController setCompletionHandler: ^(TWTweetComposeViewControllerResult result) {
[[super appViewController] dismissModalViewControllerAnimated:YES];
}];
TWTweetComposeViewController *tweetComposeViewController =
[[TWTweetComposeViewController alloc] init];
[tweetComposeViewController setCompletionHandler:
^(TWTweetComposeViewControllerResult result) {
[[ super appViewController ] dismissModalViewControllerAnimated:YES];
}];
[[super appViewController] presentModalViewController:tweetComposeViewController animated:YES];
[[ super appViewController ] presentModalViewController:tweetComposeViewController animated:YES];
}
- (void) getPublicTimeline:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{
@@ -113,7 +115,7 @@
if([urlResponse statusCode] == 200) {
NSString *dataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSDictionary *dict = [dataString objectFromJSONString];
NSDictionary *dict = [dataString JSONValue];
jsResponse = [[PluginResult resultWithStatus:PGCommandStatus_OK messageAsDictionary:dict] toSuccessCallbackString:callbackId];
[dataString release];
}
@@ -147,7 +149,7 @@
NSString *jsResponse;
if([urlResponse statusCode] == 200) {
NSString *dataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSDictionary *dict = [dataString objectFromJSONString];
NSDictionary *dict = [dataString JSONValue];
jsResponse = [[PluginResult resultWithStatus:PGCommandStatus_OK messageAsDictionary:dict] toSuccessCallbackString:callbackId];
[dataString release];
}

View File

@@ -0,0 +1,33 @@
var Twitter = function(){};
Twitter.prototype.isTwitterAvailable = function(response){
PhoneGap.exec(response, null, "com.phonegap.twitter", "isTwitterAvailable", []);
};
Twitter.prototype.isTwitterSetup = function(response){
PhoneGap.exec(response, null, "com.phonegap.twitter", "isTwitterSetup", []);
};
Twitter.prototype.sendTweet = function(success, failure, tweetText, urlAttach, imageAttach){
if(typeof urlAttach === "undefined") urlAttach = "";
if(typeof imageAttach === "undefined") imageAttach = "";
PhoneGap.exec(success, failure, "com.phonegap.twitter", "sendTweet", [tweetText, urlAttach, imageAttach]);
};
Twitter.prototype.composeTweet = function() {
PhoneGap.exec(null, null, "com.phonegap.twitter", "composeTweet", []);
};
Twitter.prototype.getPublicTimeline = function(success, failure){
PhoneGap.exec(success, failure, "com.phonegap.twitter", "getPublicTimeline", []);
};
Twitter.prototype.getMentions = function(success, failure){
PhoneGap.exec(success, failure, "com.phonegap.twitter", "getMentions", []);
};
PhoneGap.addConstructor(function() {
if(!window.plugins) window.plugins = {};
window.plugins.twitter = new Twitter();
});