Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:46:53+00:00 2026-06-10T14:46:53+00:00

I have a button called twitter,when I click this normally a view is presented

  • 0

I have a button called twitter,when I click this normally a view is presented for tweeting i.e.TWTweetComposeViewController . I have two ways of tweeting a message i.e. auto-share and normal share.Normal share is working perfectly but I have the doubt on how to do the same in auto-share means automatically tweet some default message when I click twitter button instead of showing the TWTweetComposeViewController view and click on done button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:46:55+00:00Added an answer on June 10, 2026 at 2:46 pm

    Finally I searched so many questions related to Twitter in ios5 and also read in twitter Developer Document and tried this answer.I think this is one of the solution to do auto share.

    ACAccountStore *account = [[ACAccountStore alloc] init];
            ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    
            // Request access from the user to access their Twitter account
            [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
                // Did user allow us access?
                if (granted == YES)
                {
                    // Populate array with all available Twitter accounts
                    NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
    
                    // Sanity check
                    if ([arrayOfAccounts count] > 0) 
                    {
                        // Keep it simple, use the first account available
                        ACAccount *acct = [arrayOfAccounts objectAtIndex:0];
    
                        NSURL *url = 
                        [NSURL URLWithString:
                         @"https://upload.twitter.com/1/statuses/update_with_media.json"];
    
                        //  Create a POST request for the target endpoint
                        TWRequest *request = 
                        [[TWRequest alloc] initWithURL:url 
                                            parameters:nil 
                                         requestMethod:TWRequestMethodPOST];
    
                        //  self.accounts is an array of all available accounts; 
                        //  we use the first one for simplicity
                        [request setAccount:acct];
    
                        //  The "larry.png" is an image that we have locally
                        UIImage *image = (UIImage *)[dictionarydata valueForKey:@"image"];
                        NSLog(@"%@",image);
                        if (image!=nil) {
    
                            //  Obtain NSData from the UIImage 
                            NSData *imageData = UIImagePNGRepresentation(image);
    
    
                            //  Add the data of the image with the 
                            //  correct parameter name, "media[]"
                            [request addMultiPartData:imageData 
                                             withName:@"media[]" 
                                                 type:@"multipart/form-data"];
    
                            // NB: Our status must be passed as part of the multipart form data
                            NSString *status = [NSString stringWithFormat:@"%@ %@ %@",[dictionaryData valueForKey:@"firstname"],[dictionaryData valueForKey:@"lastname"],[dictionarydata valueForKey:@"title"]];
    
                            //  Add the data of the status as parameter "status"
                            [request addMultiPartData:[status dataUsingEncoding:NSUTF8StringEncoding] 
                                             withName:@"status" 
                                                 type:@"multipart/form-data"];
                            //  Perform the request.  
                            //    Note that -[performRequestWithHandler] may be called on any thread,
                            //    so you should explicitly dispatch any UI operations to the main thread 
                            [request performRequestWithHandler:
                             ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                                 NSDictionary *dict = 
                                 (NSDictionary *)[NSJSONSerialization 
                                                  JSONObjectWithData:responseData options:0 error:nil];
    
                                 // Log the result
                                 NSLog(@"%@", dict);
    
                                 dispatch_async(dispatch_get_main_queue(), ^{
                                     // perform an action that updates the UI...
                                 });
                             }];
                        }else{
                            NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1/statuses/update.json"];
                            NSDictionary *p = [NSDictionary dictionaryWithObjectsAndKeys:
                                               [NSString stringWithFormat:@"%@ %@ %@",[dictionaryData valueForKey:@"firstname"],[dictionaryData valueForKey:@"lastname"],[dictionarydata valueForKey:@"title"]], @"status",
                                               nil
                                               ];
                            TWRequest *postRequest = [[TWRequest alloc]
                                                      initWithURL:   url
                                                      parameters:    p
                                                      requestMethod: TWRequestMethodPOST
                                                      ];
    
                            // Post the request
                            [postRequest setAccount:acct];
    
                            // Block handler to manage the response
                            [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                                NSLog(@"Twitter response, HTTP response: %i", [urlResponse statusCode]);
                            }];
    }
                    }
                }
            }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a button called WatchMode. When you click this button, it will close
I have this method that gets called when i press a button and removes
I have a button called button1 and two panels called: panelA and panelB (visible
I have a button called micro , when I click on my sound is
i have a button called ac and when i click on it, i want
I have a button called Download page at the bottom of my detailView of
I have a button called as Sync . On clicking on it, I need
I'm trying to create a UIButton programmatically. I have a button called addCash (which
I have an ASP.NET MVC Page with a button called Start Live Meeting. When
Assume we have a single Windows form with a button called SimpleButton1. The following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.