Tumblr Home Page feed - ios

I am trying to fetch Tumblr home page feed in iOS using Tumblr V2 API's.
Here is my code for the fetch feed:
-(void)requestFeed
{
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:kTumblrConsumerKey
secret:kTumblrConsumerSecret];
TumblrUser *tumblrUser = [Utils currentUser];
NSString *username = (tumblrUser!=nil)?tumblrUser.username:#"";
NSString *requestUrl = [NSString stringWithFormat:#"api.tumblr.com/v2/blog/%#/posts/queue", username];
OAToken *authToken = [[OAToken alloc] initWithUserDefaultsUsingServiceProviderName:kTumblrAccessTokenDefaultsKey prefix:#"TumblrConnect"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:requestUrl]
consumer:consumer
token:authToken
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[consumer release];
[authToken release];
[request setHTTPMethod:#"GET"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:#selector(FeedTicket:didFinishWithData:)
didFailSelector:#selector(FeedTicket:didFailWithError:)];
}
But i am getting below error in response.
Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL"
UserInfo=0x8a995a0
{NSErrorFailingURLStringKey=api.tumblr.com/v2/blog/coocku/posts/queue,
NSErrorFailingURLKey=api.tumblr.com/v2/blog/coocku/posts/queue,
NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x8c997c0
"unsupported URL"}

Add url scheme to your url
e.g.
[NSURL URLWithString:#"http://www.api.tumblr.com/v2/blog/%#/posts/queue];
OR
[NSURL URLWithString:#"https://www.api.tumblr.com/v2/blog/%#/posts/queue];

Related

iOS: Not able to get all Google People api collection list

Following is my code to get people/contacts from google account using GIDSignIn login.
Code:
- (void)setAuthorizerForSignIn:(GIDSignIn *)signIns user:(GIDGoogleUser *)user {
GTMOAuth2Authentication *auth = [[GTMOAuth2Authentication alloc] init];
[auth setClientID:signIns.clientID];
[auth setUserEmail:user.profile.email];
[auth setUserID:user.userID];
[auth setAccessToken:user.authentication.accessToken];
[auth setRefreshToken:user.authentication.refreshToken];
[auth setExpirationDate: user.authentication.accessTokenExpirationDate];
appDelegate.authGooglePlus = auth;
NSString *urlStr = #"https://people.googleapis.com/v1/people/me/connections?pageSize=200";
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:#"GET"];
auth.scope= #"https://www.googleapis.com/auth/contacts";
[auth authorizeRequest:request
completionHandler:^(NSError *error) {
NSString *output = nil;
if (error) {
output = [error description];
} else {
NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
if (data) {
output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSMutableArray *array = [[output JSONValue] objectForKey:#"connections"];
}
} else {
// fetch failed
output = [error description];
}
}
}];
}
Following is my code to fetch people/contact list, but i am able to get only 7 records not all records, Any idea how to achieve that?
The Google People API only returns contacts that are in a contact group. So likely the problem is that the other records are "other contacts", which are not in any contact group and thus are not returned.
Currently there is no way to get other contacts from the Google People API.

Is it possible to give friend request on facebook using SLRequest in ios?

I am using SLRequest to get user details and sharing on facebook and twitter. Also i am using Linkedin SDK and Google+ SDK to get user details on respective social networks. My questions are
Is it possible to give friend request on facebook using SLRequest?
Is it possible to follow a person on twitter using SLRequest?
Is it possible to connect a person on linkedin using SDK?
Is it possible to add a person on google+ using SDK?
if possible please give me a way to do that. Thanks.
After a long time, found the solution to my question,
For Facebook graph api version 2.0 does not support friend request (Refer:https://developers.facebook.com/docs/dialogs/friends/v2.0).
we can do it with twitter as follows
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {
if(granted) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
// For the sake of brevity, we'll assume there is only one Twitter account present.
// You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
if ([accountsArray count] > 0) {
// Grab the initial Twitter account to tweet from.
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
[tempDict setValue:#"MohammadMasudRa" forKey:#"screen_name"];
[tempDict setValue:#"true" forKey:#"follow"];
NSLog(#"*******tempDict %#*******",tempDict);
//requestForServiceType
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodPOST URL:[NSURL URLWithString:#"https://api.twitter.com/1/friendships/create.json"] parameters:tempDict];
[postRequest setAccount:twitterAccount];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output = [NSString stringWithFormat:#"HTTP response status: %i Error %d", [urlResponse statusCode],error.code];
NSLog(#"%#error %#", output,error.description);
}];
}
}
}];
We can do it with Linkedin as follows.
NSURL *url = [NSURL URLWithString:#"http://api.linkedin.com/v1/people/~/mailbox"];
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL:url
consumer:oAuthLoginView.consumer
token:oAuthLoginView.accessToken
callback:nil
signatureProvider:nil];
[request setHTTPMethod:#"POST"];
NSString *messageToPerson = #"/people/email=test123#test.com";
NSDictionary *person = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSDictionary alloc] initWithObjectsAndKeys:messageToPerson,#"_path",#"test123",#"first-name",#"test",#"last-name",nil], #"person",nil];
NSArray *valueArray = [[NSArray alloc] initWithObjects:person,nil];
NSDictionary *values = [[NSDictionary alloc] initWithObjectsAndKeys:valueArray,#"values", nil];
NSDictionary *ir = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSDictionary alloc] initWithObjectsAndKeys:#"friend",#"connect-type",nil], #"invitation-request",nil];
NSDictionary *update = [[NSDictionary alloc] initWithObjectsAndKeys:values,#"recipients",#"Invitation",#"subject",#"ConnectWithMe",#"body", ir, #"item-content", nil];
[request setValue:#"json" forHTTPHeaderField:#"x-li-format"];
[request setValue:#"application/json" forHTTPHeaderField:#"Content-Type"];
NSString *updateString = [update JSONString];
[request prepare];
[request setHTTPBodyWithString:updateString];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:#selector(postUpdateApiCallResult1:didFinish:)
didFailSelector:#selector(postUpdateApiCallResult1:didFail:) withPrepare:NO];
I unable to get details abt google plus add to circle.

How to get linkedin connections?

In my app user has a option to login to app through linkedin.after login i have to get user's connections. when i try to get users connections i am getting response as
{
"errorCode": 0,
"message": "Access to connections denied",
"requestId": "60A0DS1MZE",
"status": 403,
"timestamp": 1386682428799
}
Here is my code
-(void)GetConnectionsCall
{
NSURL *url = [NSURL URLWithString:#"http://api.linkedin.com/v1/people/~/connections"];
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL:url
consumer:_oAuthLoginView.consumer
token:_oAuthLoginView.accessToken
callback:nil
signatureProvider:nil];
[request setValue:#"json" forHTTPHeaderField:#"x-li-format"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:#selector(connectionsApiCallResult:didFinish:)
didFailSelector:#selector(connectionsApiCallResult:didFail:)];
}
- (void)connectionsApiCallResult:(OAServiceTicket *)ticket didFinish:(NSData *)data
{
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(#"connectionsApiCallResult====%#",responseBody);
}
- (void)connectionsApiCallResult:(OAServiceTicket *)ticket didFail:(NSError *)error
{
NSLog(#"%#",[error description]);
}
if you are using OAuth Starter Kit try this . . . .
first go to https://www.linkedin.com/secure/developer edit your App scope , make sure you have checked the r_network scope .
then go to OAuthLoginView of you project , then go to -(void) requestTokenFromProvider method .
edit you scope in below lines .
OARequestParameter *nameParam = [[OARequestParameter alloc] initWithName:#"scope"
value:#"r_fullprofile+rw_nus+r_network"];
OARequestParameter * scopeParameter=[OARequestParameter requestParameter:#"scope"
value:#"r_fullprofile rw_nus r_network"];
You need to ask for permissions.. When this is not done you are not allowed to query this information.
Everything documented here: http://developer.linkedin.com/documents/connections-api

Issue with OAuth authentication for the new Basecamp Api using OAConsumer

My code looks something like this :
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:#"my_ClientID"
secret:#"my_Secret"];
NSURL *url = [NSURL URLWithString:#"https://launchpad.37signals.com/authorization/token"];
OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
consumer:consumer
token:nil // we don't have a Token yet
realm:nil // our service provider doesn't specify a realm
signatureProvider:nil]; // use the default method, HMAC-SHA1
[request setHTTPMethod:#"POST"];
NSLog(#"USER URL : %#",[request URL]);
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:#selector(requestTokenTicket:didFinishWithData:)
didFailSelector:#selector(requestTokenTicket:didFailWithError:)];
.
- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
if (ticket.didSucceed) {
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
OAToken *requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
NSLog(#"%#",requestToken);
}
}
My Delegate method never gets a (ticket.didSucceed) Success.
Can someone tell me what I am missing here?
Thanks
It looks like you are trying to have the user authorize your app and generate the token for the first time. For this, you're using the wrong URL. From the 37Signals API:
Your app requests authorization by redirecting your user to Launchpad:
https://launchpad.37signals.com/authorization/new?type=web_server&client_id=your-client-id&redirect_uri=your-redirect-uri
The URL you are using is for getting the access token from the verification code.

Signature_invalid error from oAuth while querying for Google Request Token in IOS

I'm using oAuth to get request Token for unregistered installed app for "latitude" scope of google, i'm getting the response string as
signature_invalid
base_string:GET&https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetRequestToken&oauth_consumer_key%3Danonymous%26oauth_nonce%3D1D759072-DB2B-4E21-AA23-67CADF98C14A%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1306734462%26oauth_version%3D1.0%26scope%3Dhttps%253A%252F%252Fwww.googleapis.com%252Fauth%252Flatitude%26xoauth_displayname%3DTaj%2520Vivanta
The code i used to get request token is as follows
OAConsumer *consumer = [[OAConsumer alloc] initWithKey:#"anonymous" secret:#"anonymous"];
OAMutableURLRequest *request = [[[OAMutableURLRequest alloc] initWithURL:url consumer: consumer token:token realm:nil signatureProvider: nil] autorelease];
if (!request) return;
[request setOAuthParameterName:#"scope" withValue:[#"https://www.googleapis.com/auth/latitude" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[request setOAuthParameterName:#"xoauth_displayname" withValue:#"Taj Vivanta"];
[request setHTTPMethod: #"GET"];
OADataFetcher *fetcher = [[[OADataFetcher alloc] init] autorelease];
[fetcher fetchDataWithRequest: request delegate: self didFinishSelector: success didFailSelector: fail];
Please help me to fix this, thank you
As clearly suggested by google Document the scope and xoauth_displayname parameters should in the URL but in the above code i was placing these parameters in the request header.

Resources