views:

61

answers:

2

Hi all,

I am creating an iphone application in which I have to upload photos using different services. I am successful in uploading photos with Twitpic & YFrog but not able to do with Plixi. I am using Oauth ,as Twitter is not allowing Basic authentication.

If anyone has tried with Plixi ,please help me out!!

I have googled a lot but not getting any relevant documentation for the new Oauth for Plixi.

A: 

I'm curious as to the phrase you used in Google. In any case, googling "plixi api" tool me to this page, which links to a Cocoa wrapper on Google Code.

Joshua Nozzi
I have the same issue. Joshua, TweetPhoto has changed. It is Plixi now and the APIs are completely different. I guess the OP wants a solution for Plixi, not TweetPhoto.
lostInTransit
iphoneDev
A: 

Finally, I am with a solution for my problem :)

If anyone is also stuck with this problem, just add the TweetPhoto folder from the following application link: http://code.google.com/p/tweetphoto-api-objective-c/downloads/detail?name=TPAPI-Objective-C-Library.zip

Change the tweetphoto urls for plixi now. Also, can refer to my following code for making function calls:

-(void)uploadtoTweetPhoto{
    NSString *message = [self.tweetTextView.text stringByReplacingOccurrencesOfString:@"Max. 140 characters" withString:@""];
NSMutableDictionary *dictionary  = [[NSMutableDictionary alloc]init];


 if((message == nil) || ([message isEqual:@""])){
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Please enter your tweet message.." message: @"" delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
    [alert show];
    [alert release];
}
 else{
     [dictionary setObject:message forKey:@"message"];
 }

if([dictionary count] == 1){
    [indicator startAnimating];
    [NSThread detachNewThreadSelector:@selector(uploadPhotoToTweetPhoto:) toTarget:self withObject:dictionary];


}
[dictionary release];
}



- (void)uploadPhotoToTweetPhoto:(NSDictionary *)dictionary{

    NSString *message = [dictionary objectForKey:@"message"];
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSString *accessTokenKey = [[NSUserDefaults standardUserDefaults] valueForKey:@"oauth_token"];
    NSString *accessTokenSecret = [[NSUserDefaults standardUserDefaults] valueForKey:@"oauth_token_secret"];

    TweetPhoto *tweetPhoto = [[TweetPhoto alloc] initWithSetup:accessTokenKey identitySecret:accessTokenSecret apiKey:Plixi_API_Key serviceName:@"Twitter" isoAuth:YES];

    NSData *dat =[tweetPhoto upload:UIImageJPEGRepresentation(self.imgView.image,0.8) comment:message tags:@"" latitude:23.4646 longitude:-87.7809 returnType:TweetPhotoCommentReturnTypeXML];
    NSString *status =[NSString stringWithFormat:@"%i",[tweetPhoto statusCode]];
    [tweetPhoto release];
    [self performSelectorOnMainThread:@selector(photoUploadedtoTweetPhoto:) withObject:status waitUntilDone:[NSThread isMainThread]];
    [pool release];
}

- (void)photoUploadedtoTweetPhoto:(NSString*)status{
    [indicator stopAnimating];
    if([status isEqualToString:@"201"])
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Tweet Posted" message: @"" delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Tweet Failed" message: @"" delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
        [alert show];
        [alert release];
    }

}
iphoneDev