I am looking for a barebones facebook connection from pure actionscript to use in a mobile. Does anyone know of any examples. Been having a hard time finding what I want in Google
Thanks!
You cant connect to facebook with only actionscript - flash does not implement OAuth which you need to get a valid access token.
You have to either get an access token through PHP, or Javascript.
If you are making a mobile web-app you can check out
http://blog.yoz.sk/2010/04/facebook-now-with-oauth-and-open-graph/
Jozef Chúťka put together a great walkthrough and classes for AS3 and facebook.
So you can make a web app or use a web view in AIR to handle your authentication.
Related
In my work we often need to build Facebook apps in the form of Facebook Canvas and Website. These apps are available on Facebook direclty (an iframe) and as mobile versions (outside Facebook, in the browser).
We are working with a code base which mixes Facebook JS SDK (authentication and authorization) with PHP SDK (API calls). I find it rather dirty, and not easy to understand for people freshly working on the projects.
It's inconvinient to make API calls with JS, and making them with PHP forces extending access tokens. Authenticating user with JS SDK involves client-side redirects which are ugly to be honest, as they usually occur moments after the current page starts rendering, and so on...
I googled a lot about separating these two SDKs but did not find a clear answer to my questions:
Is it possible to create Facebook app (Canvas, Website) which bases ONLY on PHP SDK? Check login status, login, permissions, making API calls, etc. Would signed request be enough?
Is JS SDK the only full-proof way to determine user's login status at any time?
This link seems to describe what I'm thinking of, however the docs are rather brief (which seems to be a problem of Facebook documentation in general). Can anyone suggest other sources that might help? Does anyone have experience with builing FB aplications based only on server-side?
Thanks.
EDIT:
The link I posted above covers the case of not using ANY SDK, so no, it's not what I'm looking for.
You can even create an App WITHOUT any SDK - with simple CURL calls, for example. So yeah, it is indeed possible to use the PHP SDK only, but the login process is much better with the JS SDK (no redirection needed) and you can´t auto-refresh a user session like it is possible with FB.getLoginStatus afaik.
In short, i would not recommend it, the JS SDK is the very best way to authorize users and refresh Access Tokens. I would only use the PHP SDK (or simple CURL calls) for stuff that MUST happen on the server, and for stuff that includes using the App Secret, for example.
the title pretty much sums it up. Is it possible to establish a connection with facebook using flash AS3 "only", without having to work with Javascript, html, iframes or any other externals.
The reason is a simple game I was making for android using AdobeAir that connects with facebook for leaderboard purposes. Works quite well, ofcourse with AdobeAir you get the flash internal webview and ANEs to help with the facebook communication. But outside AdobeAir, as a simple web-aimed swf file you dont.
Since I was hoping to make a web-version of the game and upload it to game-hosters, I was wondering if there is a way to make a connection and wrap it up in a single swf file, since thats what these sites want for upload.
Hopes are slim, yet I would appreciate any help on this!
You need some kind of web interface to load the authorisation dialogue from Facebook. This is a popup with content running within Facebook itself, if the user then authorises your app Facebook will send a callback where you can get the access_token.
This is explained rather rudimental, the point being is that the authorisation is on Facebook ends, this is the security. In AIR you use StageWebView, in a browser you load the authorisation URL in a popup, this is implemented in the Javascript SDK for you.
You can put a button in Flash, use ExternalInterface to call methods in the Javascript SDK and send the access_token back as a callback. If you have the access_token you can use AS3 to make API calls with it in the form of HTTP requests.
Is your application a Facebook App? If your SWF is running inside the Facebook Canvas, of course it is more convenient to get the login information directly through official Javascript SDK, but if you want, this may help you. https://code.google.com/p/facebook-actionscript-api/
Any request you can write in JS, you can code in AS3 also. I don't see any problems, since FaceBook has 100% documented API.
So here is the thing...
I need a standalone flash application that receives by socket an image and then publishes it on facebook.
The few methods i've seen use php but in this case i really would like to use only the standalone.
Ideas on how to accomplish this? Is it possible?
What you're trying to do can be accomplished from the client without server scripting as well.
Have a look on these links
http://code.google.com/p/facebook-actionscript-api/
http://www.adobe.com/devnet/facebook.html
It's an AS facebook api and the Adobe site has some very useful examples on how to set this up.
After you achieve a login and you have a working connection to the Fb api then you can upload your picture to the user's albums using the api from within AS.
I am building a mobile app with jQueryMobile and I intend to deploy it onto iPhone thanks to PhoneGap.
My question is : how can I authenticate myself with Foursquare using the OAuth2 protocol in my jQueryMobile app ? One solution would be to use the useragent flow of OAuth2 but this would force the iPhone to launch Safari and thus not stay within the app. Are there any better solutions than this ?
For an iPhone-based or client-side application like you would have in PhoneGap,
Foursquare recommends one of these methods.
If you have no substantive server code, you can embed a web browser and use the token flow, redirecting the user to a dummy page on your domain. You can then grab the token off of the URL and close the browser. We have sample Android and iOS code for your reference.
If you have a server as part of your application, you can use the server flow above, possibly in an embedded browser. Similar to the Facebook API, you can add display=touch to your authorize or authenticate URLs to get a mobile optimized interface.
An alternative to the above is to use the server flow and an external browser, but redirect to a custom URI handler that brings the user back to our application. You can embed the secret in your application and exchange the provided code for an access token. PLEASE take steps to obfuscate your client secret if you include it in released code, and be prepared to rotate it if needed.
https://developer.foursquare.com/docs/oauth.html
This could probably be handled with the ClientBrowser plugin for PhoneGap or just adapting the sample code they have provided into PhoneGap plugins.
One of the core intentions of OAuth2 is to not allow browserless authentication flow like we did with XAuth in the past. Service providers want consumers to see what permissions they are signing off on, and want control of that process.
I'm not very experienced with Phonegap, as I'm a native developer, but if there's a way of instantiating a UIWebView and showing it to the user, you could at least keep the web interaction 'inside' of the application. Given phonegap is basically showing a UIWebView this should be possible. It is possible to examine the source of the html within a UIWebView using
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
I have read many articles about facebook apps, but I can't find anything what I need. Is it possible to create an App for Facebook with HTML/ CSS / Jquery without to using FBML and load this app from my server? Is it possible to use in this app the facebook functions like share, add app to my account etc? Is there any doku or example apps, where I can take a look?
Thanks
Nik
What delayed my app getting to work was realizing that the canvas URL request is HTTP POST - not HTTP GET as otherwise usual. A simple way to start is looking at example apps that have their source code open. There're examples both for PHP and python at the developer pages. A good example of a simple facebook app that uses google app engine is runwithfriends
FBML is in the process of deprecation in favor of the Graph Api for quite a while now.
Excerpt from http://developers.facebook.com/docs/reference/fbml/:
We are in the process of deprecating FBML. If you are building a new application on Facebook.com, please implement your application using HTML, JavaScript and CSS. You can use our JavaScript SDK and Social Plugins to embedded many of the same social features available in FBML. While there is still functionality that we have not ported over yet, we are no longer adding new features to FBML.
The Graph Api is easily accessible through JavaScript.
For a quick start you can use this page as a start.
First of all, fbml is not supported anymore. so forget about that.
You can write your fb app in many languages, for example you can do it in Ruby on Rails, PHP, or C#/ASP.NET etc, whatever you prefer (although you might want to look if there are some frameworks available for your platform, for using facebook. will make your life easier).
Then, setup your app from facebook developer to match your ip, and you're set to go