iphone - How to post an image to a LinkedIn account using Objective-C code on iOS? -


i able post comment linkedin not able post image. code posting comment:

  nsurl *url = [nsurl urlwithstring:@"http://api.linkedin.com/v1/people/~/shares"];   oamutableurlrequest *request =          [[oamutableurlrequest alloc] initwithurl:url                                         consumer:self.consumer                                            token:self.accesstoken                                         callback:nil                                signatureprovider:nil];   nsstring *postedstr = self.textview.text;   nsdictionary *update = [[nsdictionary alloc] initwithobjectsandkeys:                                 [[nsdictionary alloc]                                   initwithobjectsandkeys:                                  @"anyone",@"code",nil], @"visibility",                                  postedstr, @"comment", nil];   [request setvalue:@"application/json" forhttpheaderfield:@"content-type"];   nsstring *updatestring = [update jsonstring];   [request sethttpbodywithstring:updatestring];   [request sethttpmethod:@"post"];   oadatafetcher *fetcher = [[oadatafetcher alloc] init];   [fetcher fetchdatawithrequest:request                         delegate:self                didfinishselector:@selector(postupdateapicallresult:didfinish:)                  didfailselector:@selector(postupdateapicallresult:didfail:)];         // [self.view addsubview:linkedinview];    [request release]; 

any suggestion appreciated!

try bellow code may you:-

-(void)postupdatehere {   nsurl *url = [nsurl urlwithstring:@"http://api.linkedin.com/v1/people/~/shares"];   oamutableurlrequest *request =   [[oamutableurlrequest alloc] initwithurl:url                             consumer:[self getconsumer]                                token:self.accesstoken                             callback:nil                    signatureprovider:nil];    nsdictionary *update = [[nsdictionary alloc] initwithobjectsandkeys:                      [[nsdictionary alloc]                      initwithobjectsandkeys:                      @"anyone",@"code",nil], @"visibility",                      @"comment goes here", @"comment",                     [[nsdictionary alloc]                      initwithobjectsandkeys:                     @"description goes here",@"description",                     @"www.google.com",@"submittedurl",                       @"title goes here",@"title",                     @"http://economy.blog.ocregister.com/files/2009/01/linkedin-logo.jpg",@"submittedimageurl",nil],@"content",                     nil];   [request setvalue:@"json" forhttpheaderfield:@"x-li-format"];   [request setvalue:@"application/xml" forhttpheaderfield:@"content-type"];   nsstring *updatestring = [update jsonstring];   [request sethttpbodywithstring:updatestring];   [request sethttpmethod:@"post"];   oadatafetcher *fetcher = [[oadatafetcher alloc] init];   [fetcher fetchdatawithrequest:request                  delegate:self         didfinishselector:@selector(postupdateapicallresult:didfinish:)           didfailselector:@selector(postupdateapicallresult:didfail:)];  } 

i found bellow stackover flow answer:-

can't share using oauth starter kit linkedin

edit:-

for tamilking comment reply. can image url of currunt location using google api. first need currunt location image like:-

nsstring *staticmapurl = [nsstring stringwithformat:@"http://maps.google.com/maps/api/staticmap?markers=color:red|%f,%f&%@&sensor=true",lat, log,@"zoom=12&size=114x116"];    //that above staticmapurl nslog :http://maps.google.com/maps/api/staticmap?markers=color:red|1.282130,103.803131&zoom=12&size=114x116&sensor=true 

that given current location image example:-

enter image description here

now have convert above nsstring nsurl

nsurl *mapurl = [nsurl urlwithstring:[staticmapurl stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]];  

and use url want share in linkedin. hope helps you.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -