[twitter-dev] Re: Problem in posting image to Twitter using twitpic

2010-09-28 Thread sunil adhyaru
1) Header

OAuth realm=, oauth_timestamp=1285656191,
oauth_nonce=c09a1b4b650f4dcb509ae944a4324f5e0ab3b4ac,
oauth_signature_method=HMAC-SHA1,
oauth_consumer_key=pzHxyRZ7Mi8fNW25WTgCw, oauth_version=1.0,
oauth_token=190978834-DomyKA0lL7apnNQt0r52Z2cg0afuwReiPYfYYDUT,
oauth_signature=eDzy1Ed0.00QzNTDNJ1oQgReAOOZyo264908

2) Response
Null.

On Sep 27, 6:02 pm, Tom van der Woerdt i...@tvdw.eu wrote:
 Hi,

 Code looks fine. Can you show a dump of a request? (Request headers +
 Request body + Response body)

 Tom

 On Mon, 27 Sep 2010 05:38:55 -0700 (PDT), sunil adhyaru

 sunil.adhy...@gmail.com wrote:
  Hi I am using following code to post image to Twitter using twitpic.
  But I am getting server response code 401 for the same.

      ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:
  [NSURL URLWithString:@http://api.twitpic.com/2/upload.json;]];

      [req addRequestHeader:@X-Auth-Service-Provider value:@https://
  api.twitter.com/1/account/verify_credentials.json];
      [req addRequestHeader:@X-Verify-Credentials-Authorization
                      value:[oAuth oAuthHeaderForMethod:@GET
                                                 andUrl:@https://
  api.twitter.com/1/account/verify_credentials.json
                                              andParams:nil]];

      [req setData:UIImageJPEGRepresentation(imageView.image, 0.8)
  forKey:@media];

      // Define this somewhere or replace with your own key inline right
  here.
      [req setPostValue:TWITPIC_API_KEY1 forKey:@key];

      // TwitPic API doc says that message is mandatory, but looks like
      // it's actually optional in practice as of July 2010. You may or
  may not send it, both work.
      // [req setPostValue:@hmm what forKey:@message];

      [req startSynchronous];

      NSLog(@Got HTTP status code from TwitPic: %d, [req
  responseStatusCode]);
      NSDictionary *twitpicResponse = [[req responseString] JSONValue];
      textView.text = [NSString stringWithFormat:@Posted image URL:
  %@, [twitpicResponse valueForKey:@url]];
      [req release];

  Please help me to identify where  I am going wrong.

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk


[twitter-dev] Problem in posting image to Twitter using twitpic

2010-09-27 Thread sunil adhyaru
Hi I am using following code to post image to Twitter using twitpic.
But I am getting server response code 401 for the same.

ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:
[NSURL URLWithString:@http://api.twitpic.com/2/upload.json;]];

[req addRequestHeader:@X-Auth-Service-Provider value:@https://
api.twitter.com/1/account/verify_credentials.json];
[req addRequestHeader:@X-Verify-Credentials-Authorization
value:[oAuth oAuthHeaderForMethod:@GET
   andUrl:@https://
api.twitter.com/1/account/verify_credentials.json
andParams:nil]];



[req setData:UIImageJPEGRepresentation(imageView.image, 0.8)
forKey:@media];

// Define this somewhere or replace with your own key inline right
here.
[req setPostValue:TWITPIC_API_KEY1 forKey:@key];

// TwitPic API doc says that message is mandatory, but looks like
// it's actually optional in practice as of July 2010. You may or
may not send it, both work.
// [req setPostValue:@hmm what forKey:@message];

[req startSynchronous];



NSLog(@Got HTTP status code from TwitPic: %d, [req
responseStatusCode]);
NSDictionary *twitpicResponse = [[req responseString] JSONValue];
textView.text = [NSString stringWithFormat:@Posted image URL:
%@, [twitpicResponse valueForKey:@url]];
[req release];

Please help me to identify where  I am going wrong.

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk