How to test Facebook API actions locally? - facebook

I'm building a facebook app and so far so good but when I want to add an action (i.e. an article etc.) which would point to an outside url like "example.com/articles/12" it doesn't work since I'm developing using local urls like "localhost/dev/myprogram/articles/12" and Facebook obviously cannot fetch it.
What's a good way to solve this? Mind that the application doesn't exist on a live domain yet either, so I can't use that space.
I set up the app for the development with my localhost domain and since Facebook uses an iframe it works perfectly, but once I want to actually save objects it fails because of this problem.
so lets say I have an url like:
http://localhost/dev/myprogram/articles/12
then facebook first tries to parse it via
https://graph.facebook.com/?ids=http://localhost/dev/myprogram/articles/12&scrape=true
and then save the new object with something like
https://graph.facebook.com/me/myprogram:upload?article=http://localhost/dev/myprogram/articles/12
This will fail because even though Facebook can reach my localhost trough the iframe, it cant reach this page from anywhere else.
Any workarounds for this?
Thanks

What's a good way to solve this?
Either get some publicly reachable space to test your stuff on (could be a subdomain of your actual project domain, for example) – or set up your local development machine to be reachable from the interwebs, by using a DynDNS service of some sort.

Related

Having an issue with phonegap facebook login without plugin

I have a phonegap app in iOS and I'm trying to do a login with facebook. I'm using the javascript sdk. When I try to use fb.getlogin status or fb.login, not sure which, it gives me this error:
"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."
I have searched for this error, obviously, but nothing seems to solve my issue.
I looked in the facebook app settings, and everything seems to be in order.
I'm probably crazy for asking this with so little detail, but, any suggestions, ideas?
I have never used their SDK but I would have to guess that you are making the javascript calls from within your app and the SDK is saying that it doesnt recognize the URL that the call is coming from. Even though your phone doesn't have a URL (though you could give it one but that is a whole different story) it does still have an IP and that IP isnt matching what FB is expecting. I am sure you registered for a FB developer account or something like that and it asked for a URL of where the calls would be coming from. That needs to match. I dont know how you would get around this. I think you need to use the plugin.

Can I include Facebook login/API calls *without* hosting my web application online?

I'm having some trouble understanding the steps I need to take in order to make basic requests to the Facebook API. I've been reading the documentation, and having a play with the Graph Explorer, however I'm a little confused getting started.
I'm making a game application for a University submission, for which Facebook integration is a small but important part. I will be submitting this application on disk, and it will need to work when the HTML page is launched from this disk - this is where I'm getting a little stuck. I'm not sure if I'm overthinking this, but I seem to need to register as a Facebook Developer and set up an application domain. Is this necessary? I won't be able to host this application online, it will have to be submitted on disk.
So, my questions are -
Is it possible to include basic Facebook integration without hosting the application online? (Login, retrieval of a list of the user's friend's ids)
(If this is possible) what do I need to do to handle the basic 'setup' of Facebook integration? I've been looking at the Javascript SDK reference and I see I need to have my appId and channelUrl for the Loading and Initialization. I see the appId quite clearly in the App Dashboard, however it is the channelURL I am having trouble with.
I hope that makes sense :) Loading and initializing the framework and then making Graph API calls seems pretty straightforward - I'm just not sure if it's possible without hosting the application online.
Cheers!
Your page should at least be reachable via HTTP – so put a portable webserver (could be a portable Apache distribution, or something smaller) on your “disk” as well, and run your app using http://localhost/…. Add that same address (protocol and domain only, no path) in your app settings for “Website with Facebook login”.
And for the channelUrl, see https://developers.facebook.com/blog/post/2011/08/02/how-to--optimize-social-plugin-performance/

Facebook.ui method: 'apprequests' hangs only on local development environment but not on anything else

I used this guide to set up the apprequest dialog. More specifically, I am using sendRequestViaMultiFriendSelector to allow a user to select multiple friends to send the app request to. https://developers.facebook.com/docs/reference/dialogs/requests/
I set this up almost a month ago and it's been working fine on my local development environment. However, today, for whatever reason, it just hangs. I can see requests going to Facebook and all the thumbnails being returned for my friends, but it doesn't seem to get past the 'loading' image.
The other weird thing is that on all my deployment environments (i.e., staging, production), it works just fine.
I checked the Facebook App I use for local development, and I'm not too sure how this happened, but the app id and app secret had changed. I've updated them accordingly but still to no avail.
Any ideas what might be the issue?
I experienced the same issue. The following solved the problem:
Define a custom domain in the hosts file (on the local computer),
as described earlier in this thread.
Configure Visual Studio to use port 80. Don't use a custom
(or random port).
Update the facebook App settings with the custom domain.
If you use a custom port, like 4543, the facebook dialogs will hang.
http://www.lazerwire.com
make sure that your local development server and the production (or any other server you want to run the script from) runs on the same domain (or subdomain of it) as the app domain that you've set in the application setting (in facebook developers site, http://developers.facebook.com/apps )
Another possible workaround is to set display:'popup' in the FB.ui call. The described bug does not occur for this display method.

Facebook local testing: In which direction data is flowing?

This question is not about how to set up local environment to test Facebook application. Rather I've already set this up with the help of this thread. In short I changed my hosts file and its working great.
But, I've a got a doubt:
Assumption: Everywhere I've read that Facebook server works like a proxy and fetches web-pages, like a web service, from application provider's server and then sends this embedded data to browser.
For testing purposes, I've changed my hosts file like mentioned in above thread. My question is if Facebook server is fetching data from my web server then how come my browser gets this data locally after changing hosts file?
It seems either my assumption is wrong or I am missing something fundamental. Please help. Thanks.
Facebook only acts as a proxy server if you are building an FBML app. If you are building an iFrame app, the request to your application is coming directly from the client browser. You can test this out by actually setting your canvas url to something like http://localhost:8080/ and running your app locally. You will be able to run the application like normal, but obviously only you will be able to use it since it is on localhost.

Is there no longer a connect URL for using the Facebook Javascript SDK

Its quite possible I'm missing something obvious here; I hope so.
I have been trying to get a Facebook game that posts to the user's wall after the game has finished working. As I understand it, this should be a pretty simple process (and there appears to be several different approaches).
I have tried most of these, and they all seem to fail for the same reason; I do not have a 'connect' URL (which, as I understand it, is also called a canvas callback URL?) set correctly.
This sounds easy to fix, but it seems like the application settings page has recently changed. Often a 'connect' tab is referred to, but this no longer exists. All I have is a 'Facebook integration' tab and this has only the canvas URL, there doesn't appear to be a connect URL.
You need to set the URL in the Website Section. You'd be best settings the domain as well just to make sure. I find it best practise to set the URL in the Facebook Integration tab as well as then Website tab regardless of the type of Facebook integration I am creating
You are correct that the error message is out of date, the connect URL is the Website URL now (just wanted to clarify)