Twitter #Anywhere Sign in Not Sure How to use Bridge_Code - twitter

I have setup an Application that uses #Anywhere from twitter to Authenticate the users.
I moved this away from the older way I was doing it of Sending the user to a new tab, logging in to twitter, clicking authorize, and entering the PIN and username into my system because it was too many steps and users were getting confused.
The Problem I have now is I need to store the oauth_token and oauth_token_secret in the database so that I can get their information and associate it with my own userids allowing the user to reply to tweets inside the application.
However I dont get these fields when I make the call back I get an "ouath_access_token" which doesnt look very similar to the ones I was getting before using #Anywhere and also a "oauth_bridge_code"
I have seen some very vague docs on how to use this to get the real data I would like.
I tried doing something like this from a slide I had seen
$.ajax({
url:'http://api.twitter.com/oauth/access_token',
type:'POST',
data:bridge_code,
success: function(data, jqXHR){
//investigate data returned
console.log(data,jqXHR);
}
});
====================EDIT===================
Now I am getting a specific error when sending the above request
XMLHttpRequest cannot load https://api.twitter.com/oauth/access_token. Origin http://127.0.0.1 is not allowed by Access-Control-Allow-Origin.
POST https://api.twitter.com/oauth/access_token undefined (undefined)

I believe this feature is Deprecated
https://groups.google.com/forum/#!msg/twitter-development-talk/UPzE8ozWtlk/mkot6N2xBRQJ

Related

Instagram api not returning any followers although response code is 200

I am using instagram to recieve the list of people i follow and although api returns the status code 200 I recieve absolutely no data.I tried using postman client instead of my code and even from there no data is being returned I am hitting the following service.
https://api.instagram.com/v1/users/self/follows?access_token=token
one thing to be noted is my application is in sandbox mode and this same access token is working and fetching other information about the user including media shared by the user and its basic information etc and user follows and is followed by several users.
Please suggest the solution thanks in advance.
I may have answer to this question since I was facing the same issue on my WinRT project yesterday.
You may need the relationship scope instead of 'follower_list' scope.
I am assuming that you have provided the scope as 'follower_list' in the authorization URL and logged in as yourself or through your own Instagram account(the same account with which you have created your Instagram app). And now if you are hitting the above service it will return nothing in data since you are requesting if the user is following you or not(so obviously you are not following yourself)!! So if you try logging in with someone else's Instagram account and hit the above service with follower_list scope it will return your Instagram account in data if the logged in person is following you.
EDIT
The above service will return all the users that are following you AND present in your sandbox users list. (Or at least that is my conclusion on this)
For further clarification try https://apigee.com/console/instagram for hitting this service there they are using the relationship scope.

.NET - Update status (tweet) to Twitter without PIN or real Callback url?

I'm trying to write an app that can tweet using an 'application' I registered with Twitter. I am using TweetSharp and have tried to get my TwitterService set up as follows:
public Twitter(string consumerKey, string consumerSecret)
{
this.twitterService = new TwitterService(consumerKey, consumerSecret);
OAuthRequestToken oAuthRequestToken = this.twitterService.GetRequestToken();
Uri uri = this.twitterService.GetAuthorizationUri(oAuthRequestToken);
Process.Start(uri.ToString());
OAuthAccessToken oAuthAccessToken =
this.twitterService.GetAccessToken(oAuthRequestToken);
this.twitterService
.AuthenticateWith(oAuthAccessToken.Token, oAuthAccessToken.TokenSecret);
}
It gets to the OAuthAccessToken line and then takes me to the Authorize [my app] to use your account? page on the Twitter website. Before I specified a phony callback url, it displayed a page with the PIN that my user is supposed to enter when I clicked the 'Authorize app' button. Then when I added a phony callback url, it would attempt to go to that page and my code would blow to smithereens with the following error:
The remote server returned an error: (401) Unauthorized.
What I want to know is: can I tweet programatically without the need to enter a PIN or have a legitimate callback url?
Tweets must be sent in the context of a user. (Ref: POST statuses/update.) Therefore, your app must get the user's authorization (an OAuth access token) in order to send a Tweet. Since you can't get an access token without using either PIN-based authentication or a callback URL, I'm afraid that what you are asking simply cannot be done.
If, however, you just want to avoid prompting your users to enter the PIN each time they start your app, then the answer is simple: Once you have a valid access token, save it somewhere (e.g. to a file) and then reload it next time your app runs. For my WinForms app, I use .NET's built-in per-user Settings mechanism to store the Access Token and Access Token Secret. A web app would probably be better off using a database or similar to persist access tokens.
Note: If you do this, you'll also need to check the validity of the stored access token, and repeat the authorization process if it's no longer valid. The Twitter API documentation suggests using the GET account/verify_credentials method for this purpose.

Can we grant access to an app to post something on a page in facebook?

The scenario is I want to post some details on a facebook page created by me from my other app. So want to know how can we give access to app through access token means how can we get the access token for this?
Thank You
Regards
Yes, take a look at the following URL and the "Page Access Tokens" section for information on how to do obtain a token.
API - Obtain Page Token
Note, however, that there is a known issue when trying to use the links api point, if you intend to define your own link in the post.
Bug report
You'll probably want to use the feed API point instead. I've not actually managed to get this working yet though, and I'm awaiting feedback from FB themselves. I'll update you if/when I hear something useful back.
Good luck.
You can get the access_token for you page by enabling the manage_pages permission, and then calling the API endpoint: /me/accounts to get the access_token for all the pages you manage.
You can then use this access token to post to your page using the Graph API call: /{page_id}/feed

Twitter #anywhere login having issues

I'm using the new twitter #anywhere api for logging in on the client using a popup. The api docs are here
https://dev.twitter.com/docs/anywhere/welcome#auth-events
Ive created a very simple example of their api, but after hitting "connect" on the popup, twitter just says "Something is technically wrong" as seen here in this screenshot
http://cl.ly/0A321R1Z2W1o3v0P0t0z
Here is my setup for doing this (note ive already created my app on twitter)
var api = "http://platform.twitter.com/anywhere.js?id={MY_API_KEY}&v=1";
$.getScript(api,function() {
twttr.anywhere(function (tw) {
console.log("tw",tw);
// bind auth compelte event
tw.bind("authComplete", function (e, user) {
console.log("tw auth complete",e,user);
});
// calling sign in triggeers the above event
tw.signIn();
});
});
So it opens the popup, lets me sign into twitter, and then when I hit connect, i get that odd error from twitter.
Any ideas what could be going wrong?
Thanks!
Update - I found this page of people having similar problems, but the solution they offered didn't change anything.
https://dev.twitter.com/discussions/1286
And it might be important to note the domain I'm using is http://changeup.dev its a local domain. I have it setup in my hosts file already.
SO, i Figured it out. You NEED to have a callback URL for your app, (on the developer page) even though it says you don't. The callback URL needs to match your authorized domain as well.
Then, in your app, the URL that the callback is calling, NEEDS to include the twitter api. THEN, and only THEN will the window automatically close and execute the authComplete callback.
I did this on the same page I was logging in from
if(location.hash && location.hash.indexOf("oauth_access_token") != -1) {

Facebook Open Graph Scraping

I've recently enabled the Facebook Open Graph stuff on my web app (so and so has just read this and that on here and there). Now I post the request to Facebook when a user posts something, as part of the page load in the controller. The problem is I receive the following error:
HTTP 500: Response body: {"error":{"type":"Exception","message":"Could
not retrieve data from URL."}}
My first thought is that the open request to load the page is blocking any FB scraping of OG information, as it seems after it's been cached I no longer receive this error.
Is this likely? If so, what's the best way to work around it?
WHY THIS HAPPENS:
I had this same problem today, and it is because your Koala script (assuming you're using koala - if not, you should try it out because it's great) sends its request to Facebook before your URL is up. This means that when Facebook registers the post, it comes to the URL you specified to pick up the meta tags. Unfortunately, the page itself hasn't been loaded yet, giving it a 500 error
HOW TO SOLVE IT:
Use the delayed_job gem to prevent your post call from occurring before the page loads, which allows facebook to scrape your metatags correctly.
FOR EXAMPLE:
def post_to_facebook([ACCESS_TOKEN])
graph = Koala::Facebook::API.new([ACCESS TOKEN])
graph.put_connections("me", "[APP NAMESPACE]:[ACTION]", :[OBJECT TYPE] => [OBJECT_URL])
end
handle_asynchronously :post_to_facebook

Resources