App id for facebook like button for a page? - javascript

I can't be signed out if I want to get a like button for a facebook page. Yet, if I sign in, generated code adds an "appid". It shows me a list of facebook apps but there's no choice for making a button NOT for one of those apps. I just want a button for a regular facebook company page.
Is this something new or a weird bug?
Using the code that this gives me, then throws a warning in console:
"Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains."
This seems to imply that I need to make an app just to use a like button, which makes no sense.

There is no alternative. You have to create a new app for this purpose. Or using app id of any of the existing app on that page will also work fine. Anyways all the apps on the page shares same page like.

Related

HTML5 History API not working after refreshing the URL

I'm building very simple SPA 'wannabe' site /for a friend and for exercise/. The idea is simple - 3 static pages: home, portfolio, contact. I've made the links from the portfolio and contact to change the url and I just need to make some functions to change the content. So far so good, but when I refresh the page when I'm on /contact or /portfolio "page" i get error "Cannot GET /portfolio". Same happens when I try to copy and paste the link in other browser. The purpose of the site is to be able to send links and open em. Could this be achieved without server-side?
No.
You must change have a server-side, because this mode requires URL rewriting. You have to rewrite all your requests to the index of your app.
You can disable HTML5 location mode (and use hash instead).

How to detect URL scheme and prevent the default navigation to that URL in phonegap hybrid application

I have the following requirement for my application (Android, iOS):
When the application launches it displays a login.html page (which is part of the application). After logging in, the application's webview should be occupied with home.jsp from an external domain. When user clicks on logout button in home.jsp it has to navigate back to login page . On click of logout when we usewindow.location.href="login.html" then it tries to find the page on xxx domain.
Is there a way to detect this navigation URL and override the URL from javascript or phonegap properties in the application?
When I inspect window.location.href in an android emulator I get file:///android_asset/www/index.html
But I think Nathans idea of moving it to the server is a good one. You could also have one on the device if you really need to. (PErhaps you should ask the person specifiying the app achitecture how they would do it :) )
The answer is going to vary depending on how you've implemented the mentioned WebView where home.jsp is being displayed in. You did not provide any code or any specific information so the answer is going to be the same - somewhat vague...
If you've opened a new WebView, then you can't control it from JavaScript. You'll need to control it via Java or Objective-C code (you did not mention which environment you're developing for...).
For example, if you'll look in the your-app\android\native\src\com\your-app\your-app.java file, you'll see how the native layer loads the application's index.html file after the Worklight JavaScript framework has been loaded.
Similarly, you could re-use this approach in your own application to close and re-load login.html.
If you're in fact doing the mentioned re-direct from the comments, meaning you're re-using the current webview but replacing its content with external content, then I think it is expected that you've lost the context of the application, and when looking for login.html - it doesn't find it... because you've moved from app-context to web-context. They do not know each other.
I think you should not do this re-direct. Instead, you need to open a new WebView using a Cordova plug-in, and in this new WebView to display your external content.
In this Overlayed WebView, you can detect any urls that are clicked on and if the sign-out URL was detected, then close the WebView.
You can see parts of this in action in the Integrating server-generated pages in hybrid applications tutorial and accompanying sample project.
In the sample project, you can see the functions provided (where you can add yours) in android\nativeResources\src\com\IncludeExternalPages\IncludeExternalPages.java.

Website FB login redirects to blank page

I'm getting a blank permissions page on facebook login using the Javascript SDK. It was working for the last few days and I'm not sure what I changed. I don't seem to be using my app secret anywhere (I do define the API key). Are there any suggestions for troubleshooting? The Facebook debug page unfortunately just had me add some meta tags related to open graph which didn't change anything. I've tried looking at the 100s of other questions like this but can't figure it out. I tried reverting to an older version of my code so I'm pretty sure it's something with the Facebook, but it was working.
The blank page is in the popup window and has something about permissions in the URL. My site doesn't require any permissions though.
This is the URL in the login window after signing in:
https://www.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=number_I_removed&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D11%23cb%3Df8917d1784b726%26origin%3Dhttp%253A%252F%252Fpostacle.com%252Ffd565a0d8d775e%26domain%3Dpostacle.com%26relation%3Dopener%26frame%3Df12565ffe5570f2&sdk=joey&display=popup&response_type=token%2Csigned_request&domain=postacle.com&fbconnect=1&from_login=1&client_id=number_I_removed
If I reload my page I'm signed in correctly. The app ID and Client ID are the same in the URL. Not sure if they should be but wasn't specified a client ID or means of generating one.
OK, so of course I left out a critical detail: I'm using Django. Further, I'm so reliant on Django I was serving my Facebook channelUrl in a view. Facebook's API didn't like that. After reading the story of a similarly cursed fellow, I changed my ways: URL links directly to channel.html file. No more sorrows.

Twitter Cards using Backbone's HTML5 History

I'm working on a web app which uses Backbone's HTML5 History option. In order to avoid having to code everything on the client and on the server, I'm using this method to route every request to index.html
I was wondering if there is a way to get Twitter Cards to work with this setup, as currently it can't read the page as everything is loaded in dynamically with Javascript.
I was thinking about using User Agents to detect whether it's the TwitterBot, and if it is, serving a static version of the page with the required meta-tags. Would this work?
Thanks.
Yes.
At one job we did this for all the SEO/search/facebook stuff etc.
We would sniff the user-agent, and if it was one of the following sniffers
Facebook Open Graph
Google
Bing
Twitter
Yandex
(a few others I can't remember)
we would redirect to a special page that was written to dump all the relevant data about the page for SEO purposes into a nicely formatted (but completely unstyled) page.
This allowed us to retain our google index position and proper facebook sharing even though our site was a total single-page app in backbone.
Yes, serving a specific page for Twitterbot with the right meta data markup will work.
You can test your results while developing using the card's preview tool.
https://dev.twitter.com/docs/cards/preview (with your static URL or just the tags).

Sharing dynamic (javascript generated) pages on facebook

I have a web app that is completely contolled with javascript. This means there is only one request that renders the full page, everything else is json'ed to be rendered.
Facebook share uses opengraph tags in the head to control what text and image to display in the sharing, but my application is a single page, single header, so that I could use only one image for all links on the app.
We are using hashbangs (#!) to control where the user is within the application, but we also have a url rewriter that, when the user hits a URL like
http://domain/action/id
they get sent to (through a redirect header)
http://domain/#!/action/id
So, given this scenario, I want to know if there is a way to share my urls on facebook, and tell facebook to get a different image for each of my URLs.
When facebook-share gets the page, it does not process the javascript in it - but tries to search for the opengraph tags in it. so basically there is no way to share your url's on facebook and have a different picture unless you have your opengraph tags loaded in the response - without javascript. Think of what would you do if you had no javascript at all..
So what you would have to do is to load the opengraph tags in the page before you use javascript.

Categories

Resources