i'm trying to connect twitter for android. so I have downloaded the source from github. but i got a message, which is
<error>Desktop applications only support the oauth_callback value 'oob'</error>
but i already have defined it. 'public static final String REST_CALLBACK_URL = "hywtest://hywtwitter";'
i change callback_url to 'oob', i can come close to twitter, but when change a page, show pin number, and there's nothing happens.
of course, i have changed manifest too.
<data
android:host="hywtwitter"
android:scheme="hywtest" />
please help me!
You have to provide a callback URL in your Twitter Application Page in Application Details where twitter return after successful authentication.
You need to provide a placeholder callback URL on your application record on dev.twitter.com -- this placeholder allows you to perform callback-based auth with a dynamically supplied callback on the oauth/request_token step.
Related
I'm trying to share a post on my FB wall by an Android native app.
I'm following the official guide available # FBOfficial
I would know if it's possible to share a text, an image and an hashtag and also tag place or friends in the same post.
I tried to use the ShareContent class with no results.
If I use
new SharePhotoContent.Builder()...
it's not possible to add text, because the method "setQuote" is not available.
Otherwise, if I use
new ShareLinkContent.Builder()
it's not possible to add a picture.
I would also know why
setShareHashtag(new ShareHashtag.Builder())
works perfectly but
setPlaceId(String placeId)
never works, also if I add a valid placeId taken from PlaceIds
Is there a way to solve my problem?
TY in advance
Never really worked with OAuth, trying to implement it now, I want to get access token and profile data from google and facebook. Using Xamarin.Auth.
With Facebook there're no problems, I specify "http://www.facebook.com/connect/login_success.html" as redirect url and after I login it goes back to the activity I was before.
However with Google it's not as smooth - couldn't find any similar to facebook login success pages, somewhere found suggestion to use "https://www.googleapis.com/plus/v1/people/me" - added it to redirect url white list, however after sign in I would get "Redirect_url_mismatch" A native application: application nameaccording to their documentation I should use "my.package.name:" and again I added that to redirect url white list, attempted to sign in, this time after sign in screen I get to second screen where I need to confirm read permissions and after that I get very short error something like "com.my.package:/?oauthparameterX=value1...." and get redirected to permission screen again.
Here's my complete OAuth2Authenticator:
var auth = new OAuth2Authenticator(
clientId: SocialIds.GooglePlusId,
clientSecret: SocialIds.GooglePlusSecret,
scope: OAuthUrl.GoogleScope,
authorizeUrl: new Uri(OAuthUrl.GoogleAuthorize),
redirectUrl: new Uri("https://www.googleapis.com/plus/v1/people/me"),
accessTokenUrl: new Uri("https://accounts.google.com/o/oauth2/token"),
getUsernameAsync: null);
auth.AllowCancel = false;
urls:
public static string GoogleAuthorize = "https://accounts.google.com/o/oauth2/auth";
public static string GoogleScope = "https://www.googleapis.com/auth/userinfo.email";
public static string GoogleRedirect = "https://www.googleapis.com/plus/v1/people/me";
public static string GoogleUserInfo = "https://www.googleapis.com/oauth2/v1/userinfo?access_token={0}";
In the above listed code, you are not giving the redirect uri instead you are giving the scope of google api. The purpose of redirect uri is to recieve the response from google api after authorization. The response should be a code. This response code is used for accessing the access_token,refresh_token, id_token etc. So you have to recieve this code in your project side.For this purpose , the redirect uri is used.
Go to your google console, create project, add credentials, then you will be redirect to a page conatains,
You can find the authorized redirect url. Give the url , then configure your code with new redirect url . Everything will be fine after this.
I have an application that show to the user articles from news feeds.
I want to add Facebook like mechanism, that when the user push the like button,
his Facebook account will show that he is like this article.
So, I downloaded the Facebook sdk, and worked with the open graph example.
The problem is that I can't find any good example of how to to this.
I understand that I have action types, and object types. I added action type of me/og.likes and now I need to send the url of the selected article.
What I do so far is:
I have this lines, what they do is only add which type of action my application can handle.
this is working fine.
Bundle params = new Bundle();
params.putString("object", "http://samples.ogp.me/226075010839791");
Request request = new Request(
Session.getActiveSession(),
"me/og.likes",
params,
HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response
Now I want to send the actual url of the selected article, do I need to use some kind of outside url of an object or I can build object in my application and send it?
Any help would be great,
thanks.
When creating an action you must be sure that facebook robot can see the URL and correct meta tags. You can debug your page on this page. So in your case as I understand facebook can't visit your application and therefore can't determine meta tags in your app. So the solution I can offer is creating a web page which will generate meta tags depending on the $_GET[] parameter. You can pass an article ID and generate meta tags for that ID.
There is library which completely solve this issue (project page):
dependencies {
compile 'com.shamanland:facebook-like-button:0.1.8'
}
The simplest way to add like button:
<com.shamanland.facebook.likebutton.FacebookLikeButton
style="#style/Widget.FacebookLikeButton"
app:pageUrl="http://url.to.like/page.html"
app:pageTitle="Title of page"
app:pageText="Short description of page"
app:pagePictureUrl="http://url.to.like/picture.jpg"
/>
This view will be drawn in your layout:
After clicking on it you will see the dialog with official Facebook 'Like' plugin.
Read more details.
I want to post a pre-defined message on Facebook through my android application. I got everything to work except the 'properties' field. I want to post a message where it says:
More information: here
and when the user clicks on 'here', it should link to the page.
This is what I did:
Bundle params = new Bundle();
String s2 = "{'More information':{'text':'here', 'href':" + details + "}}";
params.putString("properties", s2);
where 'details' is the link to the page.
But it seems like facebook is not picking up this line. I successfully set up the caption, picture and other fields.
Any insights? Thanks!
This is by design, as far as I know, we do not support HTML in status updates. We will automatically create a link if you post a valid URL however, so I would suggest just pasting out the full link
".....More information: (www.yourURLhere.com)"
On Facebook, www.yourURLhere.com will be a clickable link.
Now i try to Implement Twitter Integration in android using twitter4j library.Few months back I successfully implemented this using a dummy call back url like "PicPuzzle://tkxel".
But now Twitter changes its scheme and now not allow to create application with dummy URL.
Now the problem is after authentication It redirect to callbackurl But not return to application.
I specify the same url in application and registration page. I refered Problem in Callback in Twitter in Android and How I can call back in Android using OAuth for Twitter?. But these solutions are now not working because now twitter not allow to create application with dummy URL. Please help me to solve this problem.
Follow below steps:
Go to Twitter Apps: https://apps.twitter.com/
Then, Go to your app.
Go to Settings Tab
In section "Callback URLs", add the below line:
twittersdk://
Click button "Update Settings" at the bottom. That's it.
Hope this works!
Create your own WebViewClient subclass.
Override shouldOverrideUrlLoading(WebView view, String url) method.
In shouldOverrideUrlLoading(), check if url.startsWith(YOUR_CALLBACK_URL) is true.
If true, retrieve "oauth_verifier" parameter from the URL and return true (true from shouldOverrideUrlLoading() prevents the WebView instance from loading the URL).
Get an access token using the value of the parameter obtained in the step 4.
Your application can get control back from the WebView instance after the step 4.
If the above steps sound cumbersome, try TwitterOAuthView. Its usage is very simple. Just call
view.start(CONSUMER_KEY, CONSUMER_SECRET, CALLBACK_URL, true, listener);
and receive the result via TwitterOAuthView.Listener interface defined as below.
void onSuccess(TwitterOAuthView view, AccessToken accessToken);
void onFailure(TwitterOAuthView view, TwitterOAuthView.Result result);
If true is given to TwitterOAuthView.start() method as the forth argument, TwitterOAuthView does not access the callback URL, and I think this behavior is what you want to implement. The source code, TwitterOAuthView.java, may be of help.