Integrating Facebook and Twitter feeds in Android application - android

I'm adding social integration to my app, and am looking for general advice how to go about it.
At the moment the app is showing feed of particular Facebook wall (authentication handled by Facebook's Android SDK) and feed for particular Twitter hashtag. That's a start, but I want these feeds to do a bit more. For Facebook:
For long feed items, user should be able to "see more", including linked pictures
Links inside feed items should work and open in browser
Like/unlike feed items
Comment on feed items
Post on the wall (create another item in feed)
Similarly, for Twitter:
Links inside tweets should work and open in browser
Reply to, and retweet tweets
Create tweets that contain the specific hashtag
Since Facebook and Twitter both have comprehensive APIs and there are enough code samples floating around, this is all technically doable, but seems a lot like reimplementing Facebook and Twitter clients. That's a lot of work to get all the little details right, maintain code for API changes,
and not really in the scope of my app.
So I'm thinking how to avoid reimplementing Facebook and Twitter clients.
Idea one: direct user to mobile versions of the respective sites and be done with it. Downside is that user will have to go through cumbersome authentication, even if there are dedicated client apps already installed and authenticated on user's device.
Idea two: plug into existing apps using intents system: if official Twitter app is installed, use that to do hashtag search. If Seesmic or Twidroid or some other twitter client is installed, use that. As a fallback, open Twitter's mobile website in browser. Similar for Facebook. Downside here is that intents for "show facebook stream" or "search tweets for X" are not standartized. Most current apps don't even have documented ways to plug into them. Using undocumented entry points in those apps is possible but would make my app hacky and brittle.
So, this question, how you've been dealing with integrating bits of Facebook and Twitter functionality in your apps, or seen done by others?

Here is a good tip about how to implement twitter/facebook oauth:
Create new activity and name it OAuthActivity.
Create new class that extends WebView.
Follow the facebook developer guide for WEB applications (not mobile ones!) and implement oauth calls inside of your WebView. For Twitter use Signpost-core with signpost-commonshttp4 to get oauth (facebook uses its own variation of oauth so you need to do it yourself).
Override WebView so it closes itself when facebook redirects your WebView subclass to your callback url.
Use OAuthActivity to return OAuth key / secret to your main activity via RunActivityForResult.
This way screen orientation change will work; you will have same architecture for FB and TW.
I have implemented it this way, yet I can not share my code (it is licensed for my company).

When I added Facebook and Twitter integration into my app (shameless plug: Secret Message), I attempted to invoke an installed Twitter client app via Intent. It wasn't fun, because there is no such thing as a "facebook/text" or "twitter/text" Intent. I know some Twitter apps create their own, but they're not universally used or even known.
So the other option is to get a list of all installed apps and filter on those you want to display in a chooser for the user to select. But retrieving a list of packages and their user-friendly names takes forever. So I hated that option.
I ended up integrating a very simple GUI for both Facebook and Twitter into my own app, and just used OAuth to authenticate users.
I hope this helps you pick your direction.

implementing Twitter integration is pretty easy on Android (you can use Twitter4J which is a pretty nice Twitter Java Library to access the public web services).
To integrate tweeting/retwreeting is basic stuff once you have authenticated your twitter user (just have a text box to allow users to enter thei 140 characters and a button to submit it - creating tweets, retweeting, replying etc is all a matter of 1 or 2 lines of code using twitter4J). The link stuff requires formating your listview to handle weblinks and open as appropriate.
The toughest part of the whole twitter integration thing is getting the OAuth stuff done - there is a tutorial on how to implement twitter and the OAuth authentication stuff here
Unfortunately, I have never tried facebook integration, but hopefully someone will be able to help out with that.

Related

Android LinkedIn without LinkedIn SDK

I want to use LinkedIn in my Android application. I am not sure whether it is right/doable or not but I want to integrate it without LinkedIn SDK. I meant to say, whenever user clicks on login button it should go to the web using webview and user will login there and it should come back. Then I should be able to access the minimal user information.
Just wanted to know whether it is possible or not!
Thank you
It's possible but you end up with a few issues.
If your app becomes successful you increase the chance of having expensive conversations with LinkedIn lawyers.
Essentially you'd be using a very unofficial and undocumented api which would be subject to change at any time.
If you're doing the project for yourself as research project or for your own internal business use then what you're looking for is to communicate between your native app and the webpage.
See search google with android javascript communicate with web page view

Facebook API/SDK like posts as of v2.8

I try to develop an android app, that displays posts of a public Facebook page and enables logged in users to like these posts.
I tried to use the POST API call /{object-id}/likes, but as of version 2.8 of the Facebook API the documentation says, that ...
... as of Nov 17, 2016 [Facebook] changed the behavior of publishing likes and only support this action with Page Access Tokens.
My first guess is, that Facebook does this to avoid apps from abusing the "like" feature. In my understanding it's only possible to like posts on pages, where the logged in Facebook user also has page access rights (a Page Access Token) to. That seems to be a very restrictive option that impedes the possibility of an app to like posts.
I also tried to use the LikeView (as recommended in the Android sharing documentation), but that seems to only work for external links, which seems to be an Open Graph object. The documentation says:
The Like button can be used to like a Facebook Page or any Open Graph object and can be referenced by URL or ID. [emphasis added by author]
When I use the LikeView on Facebook links, as returned by the /{page-id}/posts (link attribute on returned objects), the web view popup closes immediately after clicking on the LikeView button.
I'm posting this question, because I can't find any suitable information for liking Facebook posts (especially as of v2.8) via a custom Android app, even though (I think) this should be a basic feature because on Facebook liking things is one of the most used features.
Disclaimer: Sorry for not linking to more Facebook documentation references, but because of my reputation I'm not allowed to post more than one link.
You found the relevant info already: It is not possible any more via API.
It was possible up until now, but now they removed it, because it was abused too much.
https://developers.facebook.com/docs/apps/changelog#nov-17th--2016:
Deprecations
The Graph API behavior of POST and DELETE to {object-id}/likes has changed to only be accessible for Page Access Tokens. You can read more about this in our docs.
That means, only liking in the name of a page is still possible; but not any more in the name of a user.

Link to login to social Media from app

In my app I want to have a link or button that can use stored credentials to login to social media sites - say facebook. But, since I plan on having a multiple links/buttons to different sites that may use different login info, I cannot force users to login to my app using any of the social media credentials.
Please forget the storing of credentials for now - that is a different issue altogether.
My question is Can I send the user's info to Facebook to allow them to login without having to take them to the login screen? If so, where to best find the information to do that?
Sorry if this is a noob question, but I am a noob to app dev and still trying to get my direction. Any sites or links with information would be appreciated.
sorry for the answer but from my experience you need to go through Facebook API to log in an android application using facebook,same for other social network. No clue what you wanted to do use a HTTP POST with the credential ?
There is a serious security issue with what you're trying to do, because it's you're application that handles the social network credential and so you would need to encrypt them store them and so on...
So if you want to give a try to Facebook Android API it's here : https://developers.facebook.com/docs/android/getting-started/
Dealing with the Facebook API is too much easy. You will follow some steps to import it into your project. Register your App on facebook developer site. Put the facebook button into your layout.
When the user clicks on the button the API will handle all the subsequent steps starting from taking the user username and password and will reply to you with a temporary accessToken that will be valid for two months. This is the only communication way with Facebook API, if you want to give the Facebook API any info with any other way. I am sorry to tell you you will not be able to do that.

How to implement user login with Google, Facebook or Twitter in Android app?

I am trying to implement user login via social networks to my app. User should login with their google, facebook or twiter account to the app and create content that will later be sent/or synced to the app rest service.
What is the best way to do this?
I was successful with adding google and facebook sign in button and getting auth tokens from them but then i started reading on some tutorials that include account manager which is needed to implement sync adapter for data that needs to be synced with server, but as i understood i need to create my own login and add new user implementation for this to work?
Can i use social login with sync adapter, or do i need to implement my own account management?
Please point me in the right direction.
I personally avoid tutorials that "help" you to build a customized social API's interface, first because they could rely on old API version (take Facebook for example, their graph API authentication system has changed a lot through years), second because they could propose a solution that is not what you are really looking for.
Instead, why don't you simply follow the official tutorials from Facebook SDK page (https://developers.facebook.com/docs/android/scrumptious/), Google and so on?

Authorize app comes each time while posting tweet in android application

In my application some texts are posting in the Twitter. Each time while posting in the twitter "Authorize app" comes and user have to authorize the application each time while posting text in the twitter. I want user have to authorize the application for the first time not the each time. I have used the twitter sample code from the github. Please help me to solve the issues. Thanks.
You're better off using Twitter4j library, it's listed on the official site (has unofficial status though)
You most likely are using twitter-android-sdk which can only auth over WebView, which is very limiting.
The up-to-date way to use Twitter API is to use oAuth and Twitter4j can do that, check out the link above, it has examples.
UPD
Also, if posting to Twitter is not your app's main purpose (like you want to give the user the ability to share something but they won't be doing so 60% of the time), you're better off using an Intent broadcast to share your content - that way if user has Twitter app installed, they won't have to authorize in your app at all, more details here and here if you are targeting API14+

Categories

Resources