I could not make work the new linkedin sdk. It just open the login view. When i logged in then it go to linked in account/profile rather then showing the share prompt. Do anyone have any blog or example with latest sdk ?
It just wasted my 3 days. Please help.
NSArray *permissions = [NSArray arrayWithObjects:LISDK_W_SHARE_PERMISSION, nil];
[LISDKSessionManager createSessionWithAuth:permissions state:nil showGoToAppStoreDialog:YES successBlock:^(NSString *returnState)
{
NSLog(#"%s","success called!");
NSString *url = #"https://api.linkedin.com/v1/people/~/shares";
NSString *payload = #"{\"comment\":\"Check out developer.linkedin.com! http://linkd.in/1FC2PyG\",\"visibility\":{ \"code\":\"anyone\" }}";
if ([LISDKSessionManager hasValidSession])
{
[[LISDKAPIHelper sharedInstance] postRequest:url stringBody:payload
success:^(LISDKAPIResponse *response)
{
// do something with response
NSLog(#"response : %#",response.data);
}
error:^(LISDKAPIError *apiError) {
// do something with error
NSLog(#"error: %#",apiError);
}];
}
}
errorBlock:^(NSError *error){
NSLog(#"%s","error called!");
}];
//
I'm facing the same issue.This is an effective method but not a good idea: UIApplication.sharedApplication().openURL(NSURL(string: "https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn")!)
If you successfully share something via the SDK for iOS,please let me know.
Just use a URL like this and hyperlink your share button/icon/text...
https://www.linkedin.com/sharing/share-offsite/?url={url}
Source: Microsoft LinkedIn Share URL Documentation.
For example, this works for me:
https://www.linkedin.com/sharing/share-offsite/?url=http://www.wikipedia.org/
Works fine:
Related
I am trying to integrate the linkedin in my ios application.I have observed that if the app is not installed my app shows to install the linkedin application instead of redirecting to web browser like facebook and gmail does.I would like to know weather linkedin supports this kind of things i.e redirecting to webpage if application is not installed or i have to write the custom code for that If so please help me with the custom code to be written when linkedin app is not installed and also when installed.
I have written the code as below after integrating the linkedin sdk in my application.
LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, LISDK_EMAILADDRESS_PERMISSION, nil]
state:nil
showGoToAppStoreDialog:YES
successBlock:^(NSString *returnState) {
NSLog(#"%s","success called!");
LISDKSession *session = [[LISDKSessionManager sharedInstance] session];
NSLog(#"value=%# isvalid=%#",[session value],[session isValid] ? #"YES" : #"NO");
NSMutableString *text = [[NSMutableString alloc] initWithString:[session.accessToken description]];
[text appendString:[NSString stringWithFormat:#",state=\"%#\"",returnState]];
NSLog(#"Response label text %#",text);
}
errorBlock:^(NSError *error) {
NSLog(#"%s","error called!");
}
];
If the app is not installed on your device it will call error block and you have to show an alert to user that you have to download app from app store. User can click NO and then it will go with OAuth login.
-(void)loginViaLinkedIn
{
__weak __typeof(self)weakSelf = self;
[LISDKSessionManager createSessionWithAuth:[NSArray
arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, nil]
state:#"some state"
showGoToAppStoreDialog:YES
successBlock:^(NSString *returnState) {
NSLog(#"%s","success called!");
LISDKSession *session = [[LISDKSessionManager sharedInstance] session];
NSLog(#"value=%# isvalid=%#",[session value],[session isValid] ? #"YES" : #"NO");
[weakSelf getLinkedInDetail];
}
errorBlock:^(NSError *error) {
NSDictionary * userInfoDic = [error userInfo];
NSString * info = [[userInfoDic allKeys] firstObject];
if([info isEqualToString:#"You need to download the LinkedIn App in order to connect with LinkedIn"] && error.code == 3)
{
[weakSelf loginViaOAuthProtocol];
// Linkedin native app not available , login with OAuth
}
else
{
[weakSelf linkedinAuthenticationResponse:nil error:error];
}
}
];
}
You can read the official documentation about it.
"Understanding the mobile authentication user experience"
There are several possible scenarios that could occur which result in different user experiences, based on:
-Is the LinkedIn application installed on the device?
-Is the user a LinkedIn member?
-Is the user signed into the LinkedIn application on their device?
-Has the user granted your application permission to access their profile?
All of this is explained in:
https://developer.linkedin.com/docs/ios-sdk-auth#ux
I want a twitter timeline to be displayed in a View, without the user having to put your twitter account, simplemete read the tweets and hashtag, of the accounts that I have selected during the programming of the app.
Is it possible? Where do I can find info for this?
All I see includes login in twitter.
Thank you.
You can use STTwitterAPIWrapper
Firstly using Twitter you must create an app , because you must use key and secret of your app in the code.
For example :
STTwitterAPIWrapper *twitter = [STTwitterAPIWrapper twitterAPIApplicationOnlyWithConsumerKey:YourTwitterConsumerKey
consumerSecret:YourTwitterConsumerSecret];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
{
NSDictionary *parameters = #{#"q" : #"anyHashTag", #"result_type": #"recent", #"count": #"100"};
[twitter getSearchTweetsWithQuery:parameters successBlock:^(NSDictionary *searchMetadata, NSArray *statuses, NSString *refreshUrl) {
_refreshUrl = refreshUrl;
[self parseJSONString:statuses];
} errorBlock:^(NSError *error) {
//NSLog(#"-- error: %#", error);
}];
} errorBlock:^(NSError *error) {
//NSLog(#"--** error %#", error);
}];
Note:- dont direct me to the similar question, i have read them and tried using newer API from parse and facebook. but problem still persists.
It would be really helpful if someone point me in the right direction as to what might be the possible cause for this bug.
Are parse sdk and Facebook sdk not compatible any more?
i read post on this site saying issue fixed with updating parse sdk,but i m still having same issue with parse sdk 1.2.15, 1.2.16 and facebook 3.9, 3.10.
NOTE:- i can get my name,user_id,email after each time I logout and login again. but every time i hit run it shows me the above mentioned bug.
here is my code:-
-(void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication]setStatusBarHidden:YES];
[PFFacebookUtils initializeFacebook];
[FBRequestConnection
startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
userFBid = [(NSString *)[result objectForKey:#"id"] mutableCopy];
NSLog(#"user fb id %#",userFBid);
[self getNamePictureEmail];
}
}];
}
-(void)getNamePictureEmail
{
// GET NAME
NSString *nameURLString=[NSString stringWithFormat:#"https://graph.facebook.com/%#?fields=name",userFBid];
NSURL *url=[NSURL URLWithString:nameURLString];
NSData *data1=[NSData dataWithContentsOfURL:url];
// json parsing to convert json response returned by fb into dictionary
NSDictionary *allDataDictionary1=[NSJSONSerialization JSONObjectWithData:data1 options:0 error:nil];
fbUserName=[allDataDictionary1 objectForKey:#"name"];
NSLog(#"name %#",fbUserName);
[[FBRequest requestForMe]startWithCompletionHandler:^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error)
{
if (!error)
{
fbUSerEmail = [user objectForKey:#"email"];
NSLog(#"email %#",fbUSerEmail);
[self registerUser];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Facebook Sync Error" message:#"Please try login again" delegate:self cancelButtonTitle:#"Ok" otherButtonTitles: nil];
[alert show];
}
}];
// GET PICTURE
NSString *pictureURLString=[NSString stringWithFormat:#"https://graph.facebook.com/%#/picture?type=normal",userFBid];
NSURL *PictureUrl1=[NSURL URLWithString:pictureURLString];
NSData *data3=[NSData dataWithContentsOfURL:PictureUrl1];
}
Finally!
just deleted the framework path under BUILD settings -->> Search Paths deleted and added parse and facebook sdk again. It works all fine now.
hope it helps to many trying to figure it out
I want to get tweets list using Twitter Search API. But Recently twitter has launched New version-1.1 and it requires authorization. I'm using STTwitter library for interacting with Twitter API.
I'm using STTwitter_ios project which you can find from here :
https://github.com/nst/STTwitter/tree/master/ios
Now, I have written one sample function: fetchTweets. Authorization works successful and I'm getting the list if i search for the word (Without spaces or special characters). But When I try to search keyword with spaces or Special characters like "New york", #"New or York", etc.. then it returns error :
In the method ,
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
I'm getting error :
{"errors":[{"message":"Could not authenticate you","code":32}]}
- (void) fetchTweets {
STTwitterAPIWrapper *twitter = [STTwitterAPIWrapper twitterAPIWithOAuthConsumerName:OAUTH_CONSUMER_NAME consumerKey:OAUTH_CONSUMER_KEY consumerSecret:OAUTH_CONSUMER_SECRET oauthToken:OAUTH_TOKEN oauthTokenSecret:OAUTH_SECRET_TOKEN];
NSString *query = #"New york";
NSString *searchQuery = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[twitter getSearchTweetsWithQuery:searchQuery successBlock:^(NSDictionary *searchMetadata, NSArray *statuses) {
NSLog(#"Search data : %#",searchMetadata);
NSLog(#"\n\n Status : %#",statuses);
} errorBlock:^(NSError *error) {
NSLog(#"Error : %#",error);
}];
}
Any help or suggestions will be appreciated !
Thanks !
Finally, I removed OAuth token and it works fine !
See code below :
STTwitterAPIWrapper *twitter = [STTwitterAPIWrapper twitterAPIApplicationOnlyWithConsumerKey:OAUTH_CONSUMER_KEY consumerSecret:OAUTH_CONSUMER_SECRET];
[twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {
[twitter getSearchTweetsWithQuery:searchQuery successBlock:^(NSDictionary *searchMetadata, NSArray *statuses) {
NSLog(#"Search data : %#",searchMetadata);
NSLog(#"\n\n Status : %#",statuses);
} errorBlock:^(NSError *error) {
NSLog(#"Error : %#",error);
}];
} errorBlock:^(NSError *error) {
NSLog(#"-- error %#", error);
}];
I am Nicolas Seriot the creator of STTwitter.
The issue you encountered was a bug and I just fixed it.
Try to add HTML encode the keywords. For example with
[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
Some form of this has been asked/answered before but I'm still pretty hazy on the issue. I'm trying to post to a friends feed but keep getting "error com.facebook.sdk code = 5" errors when trying to use startWithGraphPath: from the new FB SDK for ios. The FBSession is active and open and the access_token appears to be correct... Here's some code:
-(void)inviteUser:(NSString *)whoever {
if ([FBSession.activeSession.permissions indexOfObject:#"publish_actions"] == NSNotFound) {
// No permissions found in session, so ask for it
[FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:#"publish_actions"] defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session, NSError *error) {
if (!error){
[self sendInvite:whoever];
}
}
}];
}
-(void) sendInvite:(NSString *)whoever {
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"A name of something", #"name",
nil];
[FBRequestConnection
startWithGraphPath:[NSString stringWithFormat:#"%#/feed", whoever]
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSString *alertText;
if (error) {
alertText = [NSString stringWithFormat:
#"error: domain = %#, code = %d",
error.domain, error.code];
} else {
alertText = #"Posted successfully.";
}
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:#"Result"
message:alertText
delegate:self
cancelButtonTitle:#"OK!"
otherButtonTitles:nil]
show];
}];
I'm still new at this, and am probably missing something basic. But I'm just not seeing it.
Fixed it. I think there were two problems:
Not having the session properly communicated inside the app (i.e. I had the FBSession open in a loginController, but not in the sendInvite controller <- not the exact names, obviously). As a result, the access_token actually wasn't active. I should have followed the FB docs and put the FBSession methods in the appdelegate.
I was using "publish_action" permissions when I believe I should have been using "publish_stream."
Works smoothly with these two changes. I do have a follow-up question, though: how to post on someone else's wall using the new SDK's native share dialog? I'll probably ask this as a separate question.