Coder Social home page Coder Social logo

androidsocialnetworks's Introduction

THIS PROJECT IS NO LONGER MAINTAINED, FEEL FREE TO FORK AND FIX IT FOR YOUR NEEDS

There is also an Android Library that is being maintained, CloudRail Android SDK that offers support for all the networks below as well as GitHub, Slack, Windows Live, and Slack.

Android Social Networks

Android Social Networks is library which makes working with social networks easier. If you sometime tried to work with social networks on android you should remember that this is a hell. You should read documentation for every social network, download SDK or use some libraries for OAuth and make http calls by yourself. This library should makes your life easier, it contains common interface for Twitter, LinkedIn, Facebook and Google Plus, just build SocialNetworkManager and configure your AndroidManiferst and you can login users, or post messages or photos or add / remove friends.

Library is still in development so more features will be added soon

Features

  • Login (Twitter, LinkedIn, Facebook, Google Plus)
  • Get person info (Twitter, LinkedIn, Facebook, Google Plus)
  • Post message (Twitter, LinkedIn, Facebook)
  • Post photo (Twitter, LinekdIn)
  • Check is user in your friends list (Twitter, LinkedIn)
  • Add to friends (Twitter, LinkedIn)
  • Remove from friends (Twitter)

Sample Application

Android app on Google Play

Getting started

First of all, you need to register you application, please check this links: Facebook, Twitter, LinkedIn, GooglePlus

Next you need to initialize mSocialNetworkManager. Build it with SocialNetworkManager.Builder and add to fragment manager.

    mSocialNetworkManager = (SocialNetworkManager) getFragmentManager().findFragmentByTag(SOCIAL_NETWORK_TAG);

    if (mSocialNetworkManager == null) {
        mSocialNetworkManager = SocialNetworkManager.Builder.from(getActivity())
                .twitter(<< TWITTER  API TOKEN  >>, << TWITTER  API SECRET  >>)
                .linkedIn(<< LINKED_IN  API TOKEN  >>, << LINKED_IN API TOKEN  >>, "r_basicprofile+rw_nus+r_network+w_messages")
                .facebook()
                .googlePlus()
                .build();
        getFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_NETWORK_TAG).commit();
    }

Now you can execute requests, for example login request:

    mSocialNetworkManager.getTwitterSocialNetwork().requestLogin(new OnLoginCompleteListener() {
        @Override
        public void onLoginSuccess(int socialNetworkID) {

        }

        @Override
        public void onError(int socialNetworkID, String requestID, String errorMessage, Object data) {

        }
    });

Including in your project

Library is still in development, so for now it's only available in staging repo.

  compile('com.github.androidsocialnetworks:library:0.3.7@aar') {
      transitive = true
  }

Important

  • Library don't manage state, you need to do it yourself.
  • If you use Google Plus login, please add this in your Activity:
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        /**
         * This is required only if you are using Google Plus, the issue is that there SDK
         * require Activity to launch Auth, so library can't receive onActivityResult in fragment
         */
        Fragment fragment = getSupportFragmentManager().findFragmentByTag(BaseDemoFragment.SOCIAL_NETWORK_TAG);
        if (fragment != null) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    }

Dependencies

##Developed By

Anton Krasov - [email protected]


License

Android Social Networks is made available under the MIT license:

The MIT License (MIT)

Copyright (c) 2014 Anton Krasov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

androidsocialnetworks's People

Contributors

antonkrasov avatar aracem avatar fenil15 avatar lukesimm avatar matantsu avatar rafaeltoledo avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidsocialnetworks's Issues

facebook part does not work with fb sdk 4+

Hi,

I know this project is not maintained longer.
But still want to seek help, if it is possible, library FB portion can be fix for FB new version 4+ or lastest.
library is very good, but new fb version removed many classes and changed functionality classes.
if it is possible or any plan to upgrade project to higher fb version, it will be good, and usable for fb new version of sdk.
thanks, for great library, really found very useful

Implement the library

Hi, I'm very new in android and I want to implement this for tests...
Can you make steps of how to implement this in Eclipse please?

Thanks,
Thiago.

Twitter getting OAuthAccessToken second time creates an Exception

With DEMO App, when logged in with Twitter, if the user clicks "Login with Twitter" again, the following exception occurs,

05-07 02:20:12.829: E/AndroidRuntime(12737): Caused by: java.lang.IllegalStateException: Access token already available.
05-07 02:20:12.829: E/AndroidRuntime(12737): at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:107)
05-07 02:20:12.829: E/AndroidRuntime(12737): at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:98)
05-07 02:20:12.829: E/AndroidRuntime(12737): at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:287)
05-07 02:20:12.829: E/AndroidRuntime(12737): at com.androidsocialnetworks.lib.impl.TwitterSocialNetwork$RequestLoginAsyncTask.doInBackground(TwitterSocialNetwork.java:246)
05-07 02:20:12.829: E/AndroidRuntime(12737): at com.androidsocialnetworks.lib.impl.TwitterSocialNetwork$RequestLoginAsyncTask.doInBackground(TwitterSocialNetwork.java:230)
05-07 02:20:12.829: E/AndroidRuntime(12737): at android.os.AsyncTask$2.call(AsyncTask.java:288)
05-07 02:20:12.829: E/AndroidRuntime(12737): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
05-07 02:20:12.829: E/AndroidRuntime(12737): ... 4 more

It is trying to fetch OAuthAccessTokan, when we already have it.

Facebook Session

Hi,

Is it possible to get the Session from facebook Login?

Cheers,

Google plus Login Bug

After Signing into google + and restarting the app , the sign in button of google + becomes enabled and clicking on it throws an exception.

AndroidSocialNetworks doesn't support Android Studio 0.8.1

Уважаемый автор обещал в ближайшее время обновить этот проект под свежую версию Android Studio и попросил меня напомнить тут ему об этом!


Вот какая ситуация сейчас:
Пытаюсь собрать проект в последней Android Studio 0.8.1 c вашей библиотекой

По вашему описанию добавляю в build.gradle

compile('com.github.androidsocialnetworks:library:0.3.2@aar') {
transitive = true
}
или
compile ('com.github.androidsocialnetworks:library:0.3.3')

В итоге получаю такое сообщение
Error:Module version com.android.support:support-v13:19.1.0 depends on libraries but is not a library itself (если поставить более старые версии support-v13, то будет ругаться также )

Strange manifest merge error while adding to project @android:name="com.facebook.LoginActivity"

Hello, its strange but when I add your lib as:

 repositories {
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots"
        }
    }
    compile('com.github.androidsocialnetworks:library:0.1.8-SNAPSHOT@aar') {
        transitive = true
    }

or as module to project I always get manifest merge error:

:app:processDebugManifest
Trying to merge incompatible /manifest/application/activity[@name=com.facebook.LoginActivity] element:
  <activity
--    @android:name="com.facebook.LoginActivity">
--</activity>
--(end reached)
  <activity
++    @android:name="com.facebook.LoginActivity"
++    @android:theme="@android:style/Theme.Translucent.NoTitleBar">
++</activity>

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merging failed. See console for more info.

What I'm doing wrong? as I understand its a bug in com.github.androidsocialnetworks:facebook:0.1.1-SNAPSHOT@aar

Calling .isConnected()

What's the best moment to call .isConnected()?

Calling it inside onSocialNetworkManagerInitialized() always returns false.

On the other hand, I find it hard to understand the correct flow. This is what I plan to do:

  • Initialize SocialNetworkManager
  • Check if user is connected to some social network with isConected() (where?).
  • If connected, perform some action (like opening a new activity). If not, the user can click the button and login with requestLogin()
  • Once requestLogin() has done, call requestCurrentPerson()to get profile info. Then save the email or whatever to a database (php/mysql in my case) and register the user.

Is this reasoning ok to you?

Anyway, the library is awesome.

Can SocialNetworkManager.Builder have a #add method?

Hi!

Thank you for this amazing lib. It helps a lot!

I'd thinking. Is possible to Builder have a #add method to add more "social networks". For example, I want Instagram integration, but the actual lib doesn't have it. So, I can extend OAuthNetwork and implement the logic needed, but, where can I register this new network for manager?

onSocialNetworkManagerInitialized please return the instance

manager.setOnInitializationCompleteListener(new SocialNetworkManager.OnInitializationCompleteListener() {
            @Override
            public void onSocialNetworkManagerInitialized() {
                //here it would be nice to have the SocialNetworkManager instance
            }
        });

AccessToken

Missing getAccessToken() method of SocialNetwork class. It would be great to have it for sending to backend.

Duplicate dex issues with Parse

When you use facebook sdk along with the parse sdk, both import the bolts library causing multiple dex issues. The fix is to use 'com.parse.bolts:bolts-android:+' in the facebook sdk instead of the jar.

manifest errors

Hi:
I have two errors in my MainActivity manifest with the classes APIDemosApplication.java and MainActivity.java.
it says that com.github.androidsocialnetworks.apidemos.activity.APIDemosApplication.java doesn't exist and the same with the other class although they do exist.
any solution???

Trouble with integrating services : project can't find a specific version of android support library

Hi,

I am trying to integrate the Google Play Services with my project. I have added the play services as a dependency to my build.gradle, but when I try to rebuild the project I get this error:

Error:A problem occurred configuring project ':app'.
 > Could not resolve all dependencies for configuration ':app:_debugCompile'.
 > Could not find com.google.android.gms:play-services:4.3.23.
  Required by:
         myproject:app:unspecified > com.github.androidsocialnetworks:library:0.3.7

In app : build.graddle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "fr.istic.mmm.myplanner"
        minSdkVersion 19
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'io.realm:realm-android:0.74.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.1'
    compile 'com.squareup:android-times-square:1.4.1@aar'
    compile 'com.beardedhen:androidbootstrap:+'
    compile 'com.google.android.gms:play-services:4.3.23'
    compile('com.github.androidsocialnetworks:library:0.3.7@aar') {
        transitive = true
    }

}

Best regards,

Not call onLoginSuccess

Hello,

very beautiful work.

Im use it in depedencies 'com.github.androidsocialnetworks:library:0.3.7@aar'

I created a class for managing the login button status and I have the code below.
When i call requestLogin(); the "login" social access form appear and i login normaly.
But when i finish authentication and social form disappear nothing happen.. never call onLoginSuccess, only onError work.. if i check social status after authentication its isConnected.

i try with global listener, apply listener on requestLogin(listener) but nothing.. only onError called.

private void makeAction() {
        if (this.mManager != null) {
            SocialNetwork social = this.mManager.getSocialNetwork(this.mSocialId);
            social.setOnLoginCompleteListener(new OnLoginCompleteListener() {
                @Override
                public void onLoginSuccess(int i) {
                    mStatus = CONNECTED;
                    setTextByStatus();

                    if (mExposedListener != null) {
                        mExposedListener.onLogin(mThis);
                    }
                }

                @Override
                public void onError(int i, String s, String s2, Object o) {
                    mStatus = ERROR;
                    setTextByStatus();
                }
            });

            switch (this.mStatus) {
                case NOT_CONNECTED:
                case ERROR:
                    this.mStatus = CONNECTING;
                    social.requestLogin();
                    break;

                case CONNECTING:
                    this.mStatus = NOT_CONNECTED;
                    social.cancelLoginRequest();
                    break;

                case CONNECTED:
                    this.mStatus = NOT_CONNECTED;
                    social.logout();

                    if (this.mExposedListener != null) {
                        this.mExposedListener.onLogout(this);
                    }
                    break;
            }
        }
    }

Thanks for your help
Sam

No SocialPerson nickname

Hello,
I'm trying to retrieve the socialPerson nickname, but it gives me cannot resolve variable!!
I searched the api-demo and it looks it is used in the showprofile fragment,
I copied the fragment and the same happened, Cannot resolve variable.

so what's wrong??

Multiple dex files define LinkedInCommunicationClient

I have an Android project in Android Studio. I have included the libraries as shown below (I only need Linkedin)

compile('com.github.androidsocialnetworks:library:0.3.2@aar')
compile files('libs/linkedin-j-android.jar')
compile files('libs/signpost-core-1.2.1.2.jar')
compile files('libs/signpost-commonshttp4-1.2.1.2.jar')

On build, I am getting the below error

UNEXPECTED TOP-LEVEL EXCEPTION:
  com.android.dex.DexException: Multiple dex files define Lcom/google/code/linkedinapi/client/LinkedInCommunicationClient;

I tried adding

{
    transitive = true 
}

as suggested by you but that yielded a minimum SDK error. So I had that removed.

Modularity

This library needs to be modular, we can just import the versions of implementations and uses an base class to provides the initial functions for the application.
We don't need non used code in code of us...

making the login state app wide ?

i have integrated this library into my app , and it for now works great on google plus , i can call a function to login in my fragment and all is good.

just one question , how can i acsess the state of the user from anywhere in the app ? (eg. isConnected() etc...)

Integration of Google+ isn't working in the same class where I integrated Facebook.

I need to to integrate both Facebook and Google Plus in the same activity but I'm not getting success in it. I have tried both in individual projects and they work fine but when I add both projects together my app gets crashed. Even I have tried them with custom buttons too but they don't work either. Currently my Facebook part is working fine but I get error when I click on Google's button. I always get error in this line of Google+ code mConnectionResult.hasResolution()

Anybody has solution of this? If yes then please provide to me.

Get user's email from Facebook & Google+

Hello everyone,

Again, as I was already telling Anton by email, congrats for the work done here, it's brilliant and really make our life easier for social networking implementation.

I'm writing here because I was wondering how to retrieve user's email.
I need it in the "login" feature of Social Networks, and only for Google+ & Facebook, and I was quite surprised it was not possible to access user's email from SocialPerson.email yet because I know Facebook Android SDK & Google+ Android API allow this 😃

So based on Anton suggestion, here's my issue ticket regarding this.

Also, here's how that could be done & implemented in Android Social Networks :
-- For Facebook

Line 166 of "FacebookSocialPerson.java" (in the "impl" folder of Social Networks) '''request.executeAsync();'''

Just before we could add
'''Bundle params = request.getParameters();
request.putString("fields", "email,name,<OTHER NECESSARY ?>");
request.setParameters(params);'''

Facebook's default approved item for an application to connect to FB's APIs include email, by default, again, so might be good for Facebook scopes already.

-- For Google+
Line 100 of "GooglePlusSocialNetwork.java" (in the "impl" folder of Social Networks)
'''Person person = mPlusClient.getCurrentPerson();'''

We could simply add after that :
socialPerson.email = mPlusClient.getAccountName();
For me, "getAccountName" possibly returns the email of the user (not always the case, but worth try it 👯 )

Maybe the scopes need to be extended compared to what Social Networks is asking. Here is what I used to ask as 'scopes' for Google+ sign in 👍

'''mPlusClient = new PlusClient.Builder(mContext, this, this).setScopes(Plus.SCOPE_PLUS_LOGIN.en(), Plus.SCOPE_PLUS_PROFILE.en()).build();'''

What do you think guys ? 😄

How to declare gradle dependency?

Hi,

Some newb question :) How can I declare the dependency for your library in my application. I tried compile 'com.github.androidsocialnetworks:0.3.4@aar' but it can't be found. Is it the correct name? Which repository should I add for gradle to find it?

Thanks,
Best,
Thibaut

Problem with Twitter Login

The first time I use the twitter login with my application it works perfectly. If i continue using the same application/device works ok.
The problem is when i use another flavour/buildType of the application or use in another device.
After set my user and password the Twitter library enter in a infinite bucle of asking for my login and pass to give access for my application. The unique solution is go to twitter page and revoke the permission for my application.

My code bellow:

...

//Configuration
public void configureSocialLibrary() {
    mSocialNetworkManager = SocialNetworkManager.Builder.from(this)
            .twitter(BuildConfig.TWITTER_CONSUMER_KEY,   BuildConfig.TWITTER_CONSUMER_SECRET)
            .build();
    getSupportFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_TAG)
            .commit();
}

...

//OnClick method to connect with twitter
@OnClick(R.id.login_btn_twitter)
public void clickLogin() {
    if (mSocialNetworkManager.getTwitterSocialNetwork().isConnected()) {
        connectWithMyStuff();
    } else {
        mSocialNetworkManager.getTwitterSocialNetwork().requestLogin(this);
    }
}
    //Twitter Login Callbacks
    @Override
   public void onLoginSuccess(int i) {
           connectWithMyStuff();
   }

@Override
public void onError(int i, String s, String s2, Object o) {
    Toast.makeText(LoginActivity.this,
            "Problem with the Twitter Login: " + s2,
            Toast.LENGTH_LONG).show();
}

Should I do anything else?

Thank you

error adding the library

i have just added the library to the build.gradle like this:

compile('com.github.androidsocialnetworks:library:0.3.7@aar') {
        transitive = true
 }

i have made no changes to the app besides that. when i try to run my app it now says:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /root/Android/Sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/matan/AndroidStudioProjects/Stars/app/build/intermediates/dex/debug --input-list=/home/matan/AndroidStudioProjects/Stars/app/build/intermediates/tmp/dex/debug/inputList.txt
  Error Code:
    2
  Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
        at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
        at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
        at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)

Login with Github using ASN.

I was wondering if we can make ASN one stop solution for integration with social networks.

How about Github integration into ASN too?
I would like to have your thoughts and any existing libraries that can speed up the implementation process.

typo in exeption

public GooglePlusSocialNetwork getGooglePlusSocialNetwork() {
        if (!mSocialNetworksMap.containsKey(GooglePlusSocialNetwork.ID)) {
            throw new IllegalStateException(>>>"Facebook wasn't initialized..."<<< typo here , should be google );
        }

        return (GooglePlusSocialNetwork) mSocialNetworksMap.get(GooglePlusSocialNetwork.ID);
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.