how can i send private message to Facebook user? - iphone

hai iam using facebook graph API to send message to facebook user and that is stored in the inbox but the message was not displayed. Is there any permission needed to post the private message when the user is online or offline,any idea or related links? Thank you for helping me.

You should use a custom url scheme. In your case fb://messaging/compose/1347150232, where 1347150232 is the userid. This will open the compose message page on the facebook app for a given user.
See also the Communicating with Other Apps:
NSURL *myURL = [NSURL URLWithString:#"fb://messaging/compose/1347150232"];
[[UIApplication sharedApplication] openURL:myURL];

Related

Facebook test user vicious circle: Publish_actions

I'm trying to post an Open Graph Story, being logged to my app with Facebook test account. Story contnents: Name shared a link.
Facebook's instructions to get a permission is a vicious circle!
To post I need a permission, For permission I got to post something.
So when I'm trying to post a story from the app. App goes to Facebook app, creates a template for post. But when press "Publish" nothing's happen.
Please, help me to solve a problem.
Our company tried everything, changed code etc, but I think it's Facebooks problem. Please, help me to find out why posts do not publish to Facebook.
PS: We do not use share dialog in this case, we are using Open Graph with API 2
If you just want to share a link then use the following code:
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:#"http://developers.facebook.com"];
[FBSDKShareDialog shareFromViewController:self
withContent:content
delegate:nil];
In the composer leave 'Say something about this...' blank and the story will show up in the Timeline as "Name shared a link"
If it is a custom OG story, then use the Share Dialog; you do not need to explicitly get publish_actions permission.
If Share Dialog does not seem to post to Timeline, set the delegate for the dialog and you can use the delegate method to investigate the cause.
-(void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error {
NSLog(#"Error: %#", error);
}
As for creating actions and objects, you can do so in your app dashboard:
https://developers.facebook.com/apps/<your-facebook-app-id>/open-graph/
If you need permissions to make Graph API calls then implement login with Facebook and it is here that you request the permissions that your app needs. For example:
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.readPermissions = #[#"public_profile", #"user_photos"];
loginButton.publishPermissions = #[#"publish_actions"];
Once you have the permissions in place you can make Graph API calls.

Is it possible to bypass the share dialog and post directly to Facebook? in share kit

i Successfully bypass the Twite dialog and post directly to Twitter In ShareKit using following Code
SHKTwitter *twitter = [SHKTwitter new];
[twitter authorize];
SHKItem *item = [SHKItem new];
[item setCustomValue:#"i am tweeting" forKey:#"status"];
twitter.item = item;
[twitter send];
item.shareType = SHKShareTypeText;
item.text = #"hi";
But now also want to apply it to Facebook. plz help me
i use above code from here
Thanks In Advance
FBGraph is much better way to use facebook API in your app.
download the FBGraph Api documents folder then add it to in your folder.
and read the instruction on facebook developer site http://developers.facebook.com/docs/reference/api/.
this is the sample code - sample code
and let me know if you have any query about it.
No it's possible to imitate the Share dialog directly.
You can use the /ID/feed connection but the user status update will appear as "via your app".

Google+ integration in iPhone [duplicate]

I have been searching for tutorials on google for posting some text on google plus. But it seems like there are none.
I have also tried to go through the docs provided by google for developers of mac and iPhone but can't find anything that will solve my problem. Also there are little information on how to get the user login to there google plus account.
I am not sure what to do for the user login, do I have to use some GTLObject or use UIWebView like foursquare for user login.
Here is a list of docs that I had went through.
http://code.google.com/p/google-api-objectivec-client/wiki/Introduction
http://code.google.com/p/google-api-objectivec-client/wiki/BuildingTheLibrary
http://code.google.com/p/gtm-oauth2/
As it turns out there are only a limited number of api's available for google + developers and that also only as GET calls according to the developer of google + page my question will not get any definite answers as google is in the process of creating new api's for accessing user information on google plus.
https://developers.google.com/+/api/
Also you can use the google client sdk provided by google but it is much easier to show a webview for user login. I managed to get the people list from google plus.
The steps are same as for getting the access token as in foursquare. Just with some small changes.
in viewdidload method.
NSString *authStr = #"https://accounts.google.com/o/oauth2/auth?client_id=client_id&redirect_uri=http://somevalidurl.com&scope=https://www.googleapis.com/auth/plus.me&response_type=token";
as a url for loading request in webview. People should note one thing here that you need to create a client id in api console for your app that is web based and not as installed for this purpose as you wont we getting any option to enter any website url for callback which is very important in this case.
and in webview delegate method webViewDidFinishLoad:
NSString *urlStr = [[webView.request URL] absoluteString];
NSArray *array = [urlStr componentsSeparatedByString:#"access_token="];
if(array.count > 1)
{
NSString *oauth_token = [[[array objectAtIndex:1] componentsSeparatedByString:#"&"] objectAtIndex:0];
//do something with the oauth token after this.
}
I wrote a code snippet to signin and post simple text to Google Plus with URL and thumb Image URL.
Try it
Take a look here:
http://code.google.com/p/google-api-objectivec-client/source/browse/#svn%2Ftrunk%2FExamples%2FBooksSample
http://code.google.com/p/google-api-objectivec-client/

How can you direct a user to add their twitter account to twitter settings using Twitter.framework?

On iOS5 is it possible to prompt and direct a user to the Twitter Settings.app area so they can add their twitter account to the phone? If so how do you do it?
As a work around I can direct them to open Settings.app but thats about it.
I just pop a browser if they don't have the twitter account on the device on an app where the budget was not large enough to implement more complex functionality, this may be useful to some people:
if([TWTweetComposeViewController canSendTweet]){
...
}else{
NSString *tweet = [NSString stringWithFormat:#"http://twitter.com/intent/tweet?source=SourceApp&text=%#", [tweetText substringToIndex:140]];
tweet = [tweet stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *webLink = [NSURL URLWithString:tweet];
[[UIApplication sharedApplication] openURL:webLink];
}
I found the solution in another SO Post:
Open Twitter settings in Settings app
Short answer is:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"prefs:root=TWITTER"]];
Tweetsheet did this by itself if tweetsheet found that if there is no account in twitter under setting then it pops an AlertView that will automatically guide user to log in on the native setting for twitter for more refer to this link http://dl.dropbox.com/u/47726728/tweet%20sheet.swf
download this file and open it in jing or drag it on your browser
As noted in a comment here, this is now default behavior in iOS since 5.1. Just open one of those widgets and if the user hasn't input an account into iOS the user will be prompted to do so.

Querying the Installed URL Handlers on iPhone

Is there some why my application can query the URL handlers that have been installed / are supported?
The use case here is that I'd like my app to allow users to send tweets using either its built in tweeting, or by using their preferred twitter client. I'd like to let them select the client from a list of those that they have on the phone (or show a list with those they have installed highlighted, or something). Another app I plan to write would also benefit from being able to check for available handlers to then provide integration possibilities to its user.
Thanks,
Benjohn
You can only find if there is a handler for a given URL via UIApplication.canOpenURL::
NSURL *url = [NSURL urlWithString:#"http://example.com"];
BOOL tweet = [[UIApplication sharedApplication] canOpenURL:url];
Unfortunately, you cannot query for all the handlers or know which application handles which urls.