gorbin / asne Goto Github PK
View Code? Open in Web Editor NEWASNE library for simple integration of social networks: Twitter, Facebook, Google Plus, LinkedIn, Instagram, Vkontakte, Odnoklassniki
ASNE library for simple integration of social networks: Twitter, Facebook, Google Plus, LinkedIn, Instagram, Vkontakte, Odnoklassniki
I get an exception using GooglePlusSocialNetwork. With Facebook all works fine but when i add
GooglePlusSocialNetwork googleNetwork = new GooglePlusSocialNetwork(this);
mSocialNetworkManager.addSocialNetwork(googleNetwork);
my app crash with this exception:
java.lang.NoSuchMethodError: com.google.android.gms.common.api.GoogleApiClient$Builder.addApi
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.onCreate(GooglePlusSocialNetwork.java:546)
at com.github.gorbin.asne.core.SocialNetworkManager.onCreate(SocialNetworkManager.java:56)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:913)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5143)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Добавь пожалуйста возможность получать id отправленного поста.
It seems that it's currently not possible to logout from another fragment.
e.q. when using GooglePlusSocialNetwork. It seems that the GoogleClientApi is required to be connected before we can log out.
However, since i am using it from another fragment the Google Client API is not connected and thus, not possible to logout.
Было бы неплохо реализовать возможность приглашать друзей в приложение.
Hello again.
How to reproduce bug:
Open example project (https://github.com/gorbin/ASNETutorial) on device, rotate device at least once and then press any of the social buttons.
Result for facebook:
Process: com.github.gorbin.asnetutorial, PID: 13770
java.lang.NullPointerException
at com.facebook.Session$AuthorizationRequest$1.startActivityForResult(Session.java:1902)
at com.facebook.Session.tryLoginActivity(Session.java:1409)
at com.facebook.Session.authorize(Session.java:1159)
at com.facebook.Session.open(Session.java:1237)
at com.facebook.Session.openForRead(Session.java:471)
at com.github.gorbin.asne.facebook.FacebookSocialNetwork.requestLogin(FacebookSocialNetwork.java:149)
at com.github.gorbin.asne.core.SocialNetwork.requestLogin(SocialNetwork.java:205)
at com.github.gorbin.asnetutorial.MainFragment$1.onClick(MainFragment.java:160)
at android.view.View.performClick(View.java:4658)
at android.view.View$PerformClick.run(View.java:19461)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5653)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
For VKontakte will be something like
Caused by: java.lang.NullPointerException: Argument 'currentActivity' cannot be null
at com.facebook.internal.Validate.notNull(Validate.java:29)
at com.facebook.Session.onActivityResult(Session.java:723)
at com.github.gorbin.asne.facebook.FacebookSocialNetwork.onActivityResult(FacebookSocialNetwork.java:535)
at com.github.gorbin.asne.core.SocialNetworkManager.onActivityResult(SocialNetworkManager.java:92)
at ru.**MyPackage***.MyLoginActivity.onActivityResult(LoginActivity.java:75)
at android.app.Activity.dispatchActivityResult(Activity.java:5734)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3696)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3743)
at android.app.ActivityThread.access$1400(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5653)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
after finishing fragment.
You get first name and last name for person from server separately. Can you add them to VkPerson class?
VkSocialNetwork.getSocialPerson()
if(jsonResponse.has("first_name")) {
firstName = jsonResponse.getString("first_name");
}
if(jsonResponse.has("last_name")) {
lastName = jsonResponse.getString("last_name");
}
socialPerson.name = firstName + " " + lastName;
Hello.
I have a problem getting Twitter Access Token. Basically, this is the function I call on my "onLoginSucess" callback:
AccessToken token = network.getAccessToken();
And then I use token.token and token.secret. But this fields are null.
For example, if I print: token.toString()
AccessToken{token='', secret='null'}
The logcat for this code is:
[INFO:CONSOLE(8)] "The value "device-width;" for key "width" is invalid, and has been ignored.", source: https://api.twitter.com/oauth/authenticate (8)
[INFO:CONSOLE(8)] "The value "1.0;" for key "initial-scale" was truncated to its numeric prefix.", source: https://api.twitter.com/oauth/authenticate (8)
[INFO:CONSOLE(8)] "The value "1.0;" for key "maximum-scale" was truncated to its numeric prefix.", source: https://api.twitter.com/oauth/authenticate (8)
[INFO:CONSOLE(8)] "Error parsing a meta element's content: ';' is not a valid key-value pair separator. Please use ',' instead.", source: https://api.twitter.com/oauth/authenticate (8)
I don't know if I'm doing something wrong.
Thanks.
Whenever i import the code i didn't get Anything. The src,gen folders are empty
Even if birthday is set on Facebook profile, facebookPerson.birthday returns 'null'
It depends on com.google.android.gms:play-services:4.3.23. Apps which user newer versions will get gradle errors: "more than one library with package name 'com.google.android.gms'"
This should be replaced with the newer libraries:
com.google.android.gms:play-services-base:6.5.87
com.google.android.gms:play-services-plus:6.5.87
с одноклассников почему-то поле email приходит пустым при запросе детальной информации
from @basnopisets,
Еще один момент - при логине в логи выводится сообщение:
D/AndroidSocialNetworks﹕ com.github.gorbin.asne.odnoklassniki.OkSocialNetwork@5351f1fchandleRequestResult: Bundle[...] : SocialNetwork.REQUEST_GET_DETAIL_PERSON
со всем содержимым SocialPerson в том числе с токеном - это серьезная дыра в безопасностиС приветом,
Олег
translate:
After login in Odnoklassniki there is log with all personal information about user - big security error
I tried your apk https://github.com/gorbin/ASNE/releases/tag/0.1
for the first three methods of posting nothing happens
for "Post Dialog" app crashes
Hi, I'm writing compile 'com.github.asne:asne-twitter:0.2.1' and I get the following error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':pettoyou'.
Could not resolve all dependencies for configuration ':pettoyou:_defaultFlavorDebugCompile'.
Could not find com.github.asne:ASNECore:0.2.1.
Required by:
pettoyouandroid:pettoyou:unspecified > com.github.asne:asne-twitter:0.2.1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
how can I be???
Hello! First of all, thanks for a great lib! :)
We are trying to implement Cross-client Identity so we can use the same client_id in web and android apps. To do so, we need to send a special scope while doing login.
Normally, when you ask for an OAuth token, the person using the device sees a challenge, asking them if it’s OK to use their identity to get at some resource or other. But in this case, the system looks at the server-side Client ID in your scope argument, notices that it’s in the same project as your Android app, and gives you the token without pestering the user; they’ve already agreed to a relationship with you, the developer who controls that project. " Source
That being said, we need to send audience:server:client_id:X, where X is the Client ID of for the Web app.
As far as we could see, we cannot change the scope it's used while getting token
token = GoogleAuthUtil.getToken(params[0],
Plus.AccountApi.getAccountName(googleApiClient), scope);
Are you planning to add a way to do so? Do you want us to do a pull request?
What about youtube account?
Can you advice ?
Gradle cannot build the project complaining against the: tag in the projects manifests.
Using Android Studio, latest build tools and latest android support lib.
I tried to load avatar for Vk account and found that avatarUrl property is always null.
After some time I found that method VkSocialNetwork.getSocialPerson searches only for "photo_200". I solved the problem by adding this code, maybe this code is more common for getting avatar url:
private SocialPerson getSocialPerson(SocialPerson socialPerson, JSONObject jsonResponse)
throws JSONException {
...
if (jsonResponse.has("photo_max_orig")) {
socialPerson.avatarURL = jsonResponse.getString("photo_max_orig");
}
...
}
I'm trying to get photos of my friends and there are not such method in ASNE.
Now i need to write my own code. For example:
final VKRequest request = new VKRequest("photos.getAll", VKParameters.from(VKApiConst.OWNER_ID, friendId, VKApiConst.COUNT, 200));
request.executeWithListener(vkRequestListener);
But it's hard to make same request to Instagram. And it requires to define own SocialNetwork class like MyInstagram. Didn't chek other social networks.
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_devProductionDebugCompile'.
Could not find com.github.asne:ASNECore:0.2.1.
Required by:
evenVoice:app:unspecified > com.github.asne:asne-twitter:0.2.1
After client logins in my app, my server creates new user, based on user_id, but I must check if this authorisation is valid. To do that I send access tokens after login to my server, server check validity, but access token from google plus is empty, why is so?
From @basnopisets,
И еще один момент - почему-то при запросе детальной информации с FB city приходит пустым, хотя в профиле город указан
translete:
And one more thing - there is null in city from FacebookPerson, but in profile city is set
Prerequisits :
Steps to reproduce :
Can you send any other errorMessage in onError()
java.lang.NullPointerException
at com.github.gorbin.asne.facebook.FacebookSocialNetwork$5.onCompleted(FacebookSocialNetwork.java:510)
at com.facebook.Request$2.onCompleted(Request.java:302)
at com.facebook.Request$4.run(Request.java:1666)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5139)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)
I've updated Android Studio to version 0.9, and gradle build tools to version 0.14, now when i try to build my application (which is using ASNE) I got this error:
Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute
I've searched in my code, and I'm not using tools:node="replace" anywhere, but ASNE is using in manifest (both in core and "modules").
Any idea how I can solve this problem?
got the following message: {"error": "invalid_request", "error_description": "sdk options is undefined"}
Even if name of the city is set on Facebook profile, facebookPerson.city returns 'null'
How can add additional scopes for google network?
I integratin ASNE library in a base activity that let use login in all the screens of the application.
The problem is that SocialNetwork inicialization needs a Fragment to be instanciate.
I can instanciate a SocialNetwork with the SocialNetworkManager fragment but if I make this:
public final void configureSocialLibrary() {
mSocialNetworkManager = new SocialNetworkManager();
mSocialNetworkManager.addSocialNetwork(getTwitterSocialNetwork());
mSocialNetworkManager.addSocialNetwork(getFacebookSocialNetwork());
mSocialNetworkManager.addSocialNetwork(getGoogleSocialNetwork());
getSupportFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_TAG).commit();
mSocialNetworkManager.setOnInitializationCompleteListener(this);
}
It crash in the SocialNetwork class trying to get the SharedPreferences.
In the tutorial the solution is pass the Fragment that controls the buttons and that stuff instead of pass the SocialNetworkManager but this is not possible because I dont need Fragments to make the login -- remember I want to make login in every part of the app.
I try, of course, of add the social networks before commit the social manager but doesn't works for evident reasons.
Are there some solution for this or I need to make a fork with a builder with Fragment and Activity to fix the problem?
When trying to login with linkedIn. I get error message "invalid redirect_uri. This value must match a URL registered with the API Key." in the webview.
On add to manager GooglePlusSocialNetwork (after init) fatal exception
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoSuchMethodError: com.google.android.gms.common.api.GoogleApiClient$Builder.addApi at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.onCreate(GooglePlusSocialNetwork.java:546) at com.github.gorbin.asne.core.SocialNetworkManager.onCreate(SocialNetworkManager.java:56)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:913)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5143)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
VK SDK class VKRequest provides method setPreferredLang(String lang) and also has field useSystemLang that currently set to false in the source code of class VkSocialNetwork.java, that leads up to results from VK in English, though it is necessarily to get results in Russian
If a user receives an access token but does not complete the login until it expires, the user will not be able to log in. This could also be seen if the user revokes the access token. This is due to the GoogleAuthUtil caching the access token on the device for an unknown period of time.
In the code written below, the access token is checked for validity, and if not valid, it will clear the cached token and request a new one.
I can send in a pull request if you would like.
@Override
public void requestAccessToken(OnRequestAccessTokenCompleteListener onRequestAccessTokenCompleteListener) {
super.requestAccessToken(onRequestAccessTokenCompleteListener);
AsyncTask<Activity, Void, String> task = new AsyncTask<Activity, Void, String>() {
@Override
protected String doInBackground(Activity... params) {
String scope = "oauth2:" + Scopes.PLUS_LOGIN;
String token;
String error = null;
try {
token = GoogleAuthUtil.getToken(params[0],
Plus.AccountApi.getAccountName(googleApiClient), scope);
try {
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 20000);
HttpConnectionParams.setSoTimeout(httpParameters, 20000);
HttpClient client = new DefaultHttpClient(httpParameters);
String url = "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=" + token;
HttpGet httpGet = new HttpGet(url);
HttpResponse response = client.execute(httpGet);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder = new StringBuilder();
for (String line = null; (line = reader.readLine()) != null; ) {
builder.append(line).append("\n");
}
JSONTokener tokener = new JSONTokener(builder.toString());
JSONObject finalResult = new JSONObject(tokener);
error = finalResult.getString("error");
} catch (Exception e) {
//Probably shouldn't use Exception E here but there are quite a few
//http/io/json exceptions that could occur
}
if (error != null && error.equals("invalid_token")) {
GoogleAuthUtil.clearToken(params[0], token);
token = GoogleAuthUtil.getToken(params[0],
Plus.AccountApi.getAccountName(googleApiClient), scope);
}
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
return token;
}
@Override
protected void onPostExecute(String token) {
if(token != null) {
((OnRequestAccessTokenCompleteListener) mLocalListeners.get(REQUEST_ACCESS_TOKEN))
.onRequestAccessTokenComplete(getID(), new AccessToken(token, null));
} else {
mLocalListeners.get(REQUEST_ACCESS_TOKEN).onError(getID(), REQUEST_ACCESS_TOKEN, token, null);
}
}
};
task.execute(mActivity);
}
Facebook access token is blank string. how can i get it? i have done login, than i ask it with requestAccessToken(callback), but in onRequestAccessTokenComplete token is blank
I get a NullPointerException when calling VkSocialNetwork.isConnected()
java.lang.NullPointerException: Attempt to read from field 'com.vk.sdk.VKAccessToken com.vk.sdk.VKSdk.mAccessToken' on a null object reference
at com.vk.sdk.VKSdk.isLoggedIn(VKSdk.java:405)
at com.github.gorbin.asne.vk.VkSocialNetwork.isConnected(VkSocialNetwork.java:192)
...
java.lang.NullPointerException
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.getSocialPerson(GooglePlusSocialNetwork.java:341)
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.access$300(GooglePlusSocialNetwork.java:70)
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork$5.onResult(GooglePlusSocialNetwork.java:482)
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork$5.onResult(GooglePlusSocialNetwork.java:474)
at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.deliverResultCallback(Unknown Source)
at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5139)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)
During app creation fulfil "Список разрешённых redirect_uri" with "okauth://okXXXXXXXXXX"
Hi,
I need to get a token which will be sent to the server and used there to get the user's information.
From my understanding LinkedIn uses a different token for this situation. Is it possible to get this token using ASNE?
I can't override onError for OnRequestAccessTokenCompleteListener.
Could you check if G+ generates access token for you once more please?
I get a NullPoineterEcxeption when I try to instantiate a SocialNetwork.
VkSocialNetwork vk = new VkSocialNetwork(new Fragment(), VK_APP_ID, vkScope);
java.lang.NullPointerException
at com.github.gorbin.asne.core.SocialNetwork.<init>(SocialNetwork.java:127)
at com.github.gorbin.asne.vk.VkSocialNetwork.<init>(VkSocialNetwork.java:142)
Since I don't use any fragments in my app, I've created a separate class for working with ASNE, so I can't pass "this" as first parameter (like in your tutorial) and I've decided to just create a new Fragment. But it doesn't seem to work. I've also tried passing mSocialNetworkManager fragment as first parameter and got the same exception.
Hi!
My app receive token, expired time and other (witch were save before) from server side, and I want to initialize SocialNetwork object with received tokens. May be, you add this function to SocialNetwork class?
Here is the result from onRequestAccessTokenComplete callback - in case of using VK token field contains toString() representation of com.vk.sdk.VKAccessToken object:
AccessToken{token='com.vk.sdk.VKAccessToken@5359eaec', secret='null'}
Please give us option to disable AlertDialog (or manually handling errors) during VK authorization. I'm talking about VkSocialNetwork.java:107
@Override
public void onAccessDenied(VKError authorizationError) {
new AlertDialog.Builder(VKUIHelper.getTopActivity())
.setMessage(authorizationError.toString())
.show();
}
I would like if method onError(int networkId, String requestID, String errorMessage, Object data) be called for listeners instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.