Logout from Instgram in my website - logout

I have integrated login with Instagram feature in my website using provided API successfully.
Now i have implement the feature of logout from Instagram and then website should redirect to home page of website. But I am not getting a way to do this, please help me in this matter. I have tried lots of solutions given by other people.

First : Destroy all session variables of website on logout page to logout from your website.
Second: Use below JavaScript code to logout from Instagram
var s = document.createElement("script");
s.src = "https://instagram.com/accounts/logout";
$("head").append(s);

Related

How do you create a mobile friendly Like Gate for a Page on Facebook?

I've put a Like Gate on a few of my Facebook Pages and I'm getting a lot of complaints saying that people can't access the content via their mobile device since the mobile version of the facebook website, and the facebook apps for ios/android, don't support tabs on Facebook.
I see there are services out there (I'm not sure how legit they are) that offer a way to create a mobile like gate for your page tab, but I can't find any documentation on how they do it. These services are not suitable for me, because the content on my tab is custom and dynamic.
So, how can I create a interstitial page for a mobile page that requires the visitor to have liked my Page on Facebook before they can proceed? This has to work for new users, as well as existing users who re-visit the tab and without requiring an install to an application.
Thanks!
One approach you can take for a mobile site is to check that the user has liked the page in question via the JS SDK.
If you have a logged-in user to your application, you can Subscribe to the authResponseChange FB event within your JS SDK initialization, or call a function directly to make an API request to verify if the user is a fan of your page.
In your initialization:
FB.init({appId: YOUR_FB_APP_ID_HERE });
window.fbAsyncInit = function() {
// React to a user clicking an on-page Like button:
FB.Event.subscribe("edge.create", verifyUserLikesPage);
}
You can verify that the user likes the appropriate page in the like handler:
function verifyUserLikesPage() {
FB.api("/me/likes/"+FBID_OF_PAGE_TO_ENSURE_THEY_LIKE, function(apiResponse){
if (apiResponse.data && apiResponse.data.length > 0)
// User likes the page. Enabled them to proceed
else
// User does not like the page. Require they click Like.
}
}
More information on the edge.create subscribe via JS available here: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Google Chrome Extension + Login with Facebook + Parse

I'm trying to build a google chrome extension, a use case requires that users can login with Facebook and share via a post to their Facebook wall.
The correct application flow would be as such:
User click google chrome extension - summons extension page
User clicks "login with facebook" on the extension page (or in a new tab) the users then see the "approve app" from Facebook
The user approves the app
The user is directed to a new page that thanks them for installing and processes all the needed user information OR the user is sent back to the google chrome extension (better way)
If the user is not sent back to the google chrome extension, they should be told to do so, but at this point how to get the data to the google chrome extension?
The user opens to the Google chrome extension, they should now see "Hi John" or similar instead of "Login with Facebook"
The user can no post to Facebook
My major hick-ups are logging in with Facebook, and getting the data back to the extension.
I've created a Facebook app, done most of the coding specific to the app, I'm trying to keep the app just javascript (but I can add in php if there is no other way), tried using the standard Facebook javascript, and tried using the desktop client for Facebook.
Anyone else gone through this process of connecting Google Chrome Extensions and Facebook login before?
As a final note, I'm trying to with with Parse for this project, so if you have any extra insite on that it would be great too!
A good example of what I'm trying to accomplish is similar to what Any.do
https://chrome.google.com/webstore/search/any.do?utm_source=chrome-ntp-icon
I had this kind of problem lately ;). It's a bit complicated, but I'll try to explain it in the simplest way.
Put somewhere in your extension (maybe options page) link "login with facebook" that redirects to: https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&response_type=token&scope=<PERMISSIONS>&redirect_uri=http://www.facebook.com/connect/login_success.html
When someone clicks on this link, will be asked to give permissions, etc (facebook page). If someone would agree, the page will load: http://www.facebook.com/connect/login_success.html with parameters access_token and expires_in in address.
Now, background page should have script like this:
var successURL = 'www.facebook.com/connect/login_success.html';
function onFacebookLogin(){
if (!localStorage.getItem('accessToken')) {
chrome.tabs.query({}, function(tabs) { // get all tabs from every window
for (var i = 0; i < tabs.length; i++) {
if (tabs[i].url.indexOf(successURL) !== -1) {
// below you get string like this: access_token=...&expires_in=...
var params = tabs[i].url.split('#')[1];
// in my extension I have used mootools method: parseQueryString. The following code is just an example ;)
var accessToken = params.split('&')[0];
accessToken = accessToken.split('=')[1];
localStorage.setItem('accessToken', accessToken);
chrome.tabs.remove(tabs[i].id);
}
}
});
}
}
chrome.tabs.onUpdated.addListener(onFacebookLogin);
And this is how you get access token from facebook. Now you can send requests to https://graph.facebook.com.
Hope I helped ;)
To answer your question (Don't have enough credit to comment).
In your Facebook developer settings, click the advanced tab at the top, make sure "Client OAuth login" & "Embedded browser OAuth login" are both moved to "Yes" and then I had to add "http://www.facebook.com/" to the Valid OAuth redirect URI's
now facebook has changed "Client Oauth Login" button location. You need to add a product and after adding facebook login you will found here

Facebook C# SDK for Facebook Connect

How can I use Facebook C# SDK for facebook connect using ASP.NET?
What I am trying to do is:
Provide a "Login with Facebook" button.
Once the user clicks on Login button, get the access token on server side and sign in to my website.
Most articles (I found through google or SO) said use Facebook Javascript SDK for Log in and Authentication and then get the Access token from cookies created on web browser.
What I did so far:
Used Facebook login button in .aspx page with the below code.
<fb:login-button onlogin="window.location.reload();" perms="offline_access">Login with Facebook</fb:login-button>
Problems I am having:
When I click log in button on MY PAGE a window will pop up to log in to facebook. MY PAGE is supposed to reload when I login to facebook but it reloads even I click on Cancel button or close the pop up window. What I need is reloading MY PAGE only when I log in.
From the above step: If I log in and MY PAGE reloads perfectly. In code behind (Page load event) I can see the cookie created and it has the information (access token) what I needed. And from here I want to use Facebook C# SDK to get user information. how to do ?
I used Facebook C# SDK 3 months ago for developing a canvas application in Facebook. The documentation and examples listed on Codeplex are for Apps on Facebook (correct me if I missed to see facebook connect examples). Also, there was a link to documentation which lists all the Facebook C# SDK classes but I could not see that now. Please provide me the link if you know.
Any help will be greatly appreciated.
Thank you.
http://blog.prabir.me/post/Facebook-CSharp-SDK-Writing-your-First-Facebook-Application-v6.aspx
But there is one issue I am not using
parameters.response_type = "token";
Instead of that i have function to update Token
public static void UpdateToken()
{
var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
{
client_id = AppId,
client_secret = AppSecret,
redirect_uri = Url,
code = FacebookUtils.FacebookData.Code
});
FacebookData.AccessToken = result.access_token;
}

Facebook Share not working while logged in with Facebook Connect

I have a Drupal 6 website where I've implemented Facebook Connect with the JavaScript SDK and it's been working fine for some months.
The site used the old Facebook Share button (pointing to sharer.php) but that didn't work with the new Facebook Connect API so I replaced it with fb:share-button.
My problem is that the Facebook share button doesn't work for users logged in via Facebook Connect. The lightbox for Facebook Share appears empty with just the loading bars. If the user is logged in to the site as a non Facebook Connect user then Facebook share works normally.
I've searched for similar problems and found an unanswered post at Facebook developer forum that looks like a similar problem.
This site also uses Facebook Like buttons but those, as far as I know, don't allow including an image from the liked image like share does. The owner of the site needs Facebook Share and has no plans of removing it to work just with Facebook like.
Any suggestions?
Thanks.
I got this code working for sharing
function share(){
var share = {
method: 'stream.share',
u: document.getElementById('txtShare').value
};
FB.ui(share, function(response) { console.log(response); });
}

How to authenticate multiple entry points in a facebook app?

I am using an IFrame application with XFBML and the new Javascript API.
I'd like to have a facebook application with multiple entry points. These will most likely represent different links coming from a fan page tab.
I can do this quite easily if the pages don't require authentication - for instance I can create several pages under the app and if a new user comes I can send them to any page:
http://apps.facebook.com/myapp/offers
http://apps.facebook.com/myapp/game
http://apps.facebook.com/myapp/products
The problem is that if I need to have authentication then once the user is authenticated they get redirected to my default post-authorization url.
Is there a way for a user that comes to /game to stay on /game after they are authenticated without redirecting.
I thought I could do it with the AJAX login form - but I cannot find out how to do that in a Facebook IFrame application.
I think the example using requirelogin only works for FBML.
<a href="http://apps.facebook.com/mysmiley" requirelogin=1> Welcome to my app</a>.
Is there a way to accomplish this with Facebook APIs - or will I have to do some kind of clever cookie handling?
You can use the facebook connect JS library inside of an iframe app and then redirect them to the appropriate url in javascript if they click allow. Best to go to the Facebook dev docs on the Javascript SDK on Fb:login here: http://developers.facebook.com/docs/reference/javascript/
Basically if the login is successful, you will get a callback where you should redirect them in javascript by using window.top.location = 'yoururlhere';