问题
Iam implementing facebook and twitter using sharekit for an iphone app. How can we get the user id of the logged in user so that I could send it to the server. Any help will be greatly appreciated. Thank you.
回答1:
you can get facebook user information using new facebook graph APIs for sample code you can use this.
回答2:
Did you try Step 3 of the installation for Sharekit?
Step 3: Filling in API Keys
Most of the web services that ShareKit integrates require you to use an API key when connecting. An API key is a unique identifer that tells the service what app is making the request.
You have to sign up for each api key, but they are all free and sign-ups are quick.
Locate and open the file SHKConfig.h, just inside the ShareKit group in your project's file list.
At the top you'll find a list of services that require api keys. Each service has a link next to it. Follow the link for each service to get an api key. Fill in the api key for each corresponding service within SHKConfig.h.
Note: Follow the comments within the SHKConfig file, they provide additional steps and possible customizations for each service.
For the full documentation see http://www.getsharekit.com/install/ and http://www.getsharekit.com/docs/
回答3:
I don't know about the textual user name, but if you are after the id -
Take a look at ShareKit's SHKFacebook class. It has an FBSession member called session. An FBSession has a FBUID which is just a typedef for long - but I'm assuming it represents some form of user ID.
回答4:
you can get the ID's by extending the enum in sharetype . add type as ID . and when you can share function introduce the case for ID checking .
- (void)getFollowers
{
OAMutableURLRequest *oRequest = [[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://api.twitter.com/1/followers/ids.json?cursor=-1&screen_name=%@", SHKTwitterUsername]]
consumer:consumer
token:accessToken
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[oRequest setHTTPMethod:@"GET"];
//NSString *message=[NSString stringWithFormat:@"status=oh man! OAuth u almost killed me! more info at http://dev.twitter.com"];
//[request setHTTPBody:[message dataUsingEncoding: NSUTF8StringEncoding]];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
//todo : handle for error callback
[fetcher fetchDataWithRequest:oRequest
delegate:self
didFinishSelector:@selector(getListsTokenTicket:didFinishWithData:)
didFailSelector:nil];
}
回答5:
If you need some user info, user name etc, this problem is solved in reborn ShareKit. See FAQ.
来源:https://stackoverflow.com/questions/4772378/getting-user-id-of-facebook-and-twitter-in-sharekit