Please be forgiving, as I know that I'm not following traditional JS standards.
function onPubFacebookBtn(){
/* On Facebook Login */
var myToken = window.localStorage.getItem("FBToken");
if (myToken != null) {
alert('This token already exists on this device.\n\n' + myToken);
}
else
{
var my_client_id = "Your App ID",
my_redirect_uri = "http://www.facebook.com/connect/login_success.html",
my_display = "touch"
var authorize_url = "https://graph.facebook.com/oauth/authorize?";
authorize_url += "client_id="+my_client_id;
authorize_url += "&redirect_uri="+my_redirect_uri;
authorize_url += "&display="+my_display;
authorize_url += "&scope=publish_stream"
cb = window.plugins.childBrowser
cb.onLocationChange = function(loc){ facebookLocChanged(loc); };
if(cb != null) { cb.showWebPage(authorize_url); }
}
}
function ClearLocalStorage(){
window.localStorage.clear();
app.navigate("#tabstrip-home");
}
function facebookLocChanged(loc){
/* Here we check if the url is the login success */
if (/login_success/.test(loc)) {
var fbCode = loc.match(/code=(.*)$/)[1]
window.localStorage.setItem("FBToken",fbCode);
window.plugins.childBrowser.close();
app.navigate("#tabstrip-home");
}
}
25 Answers, 1 is accepted
However, a moderator might want to move this to the code snippets section.
great suggestion we will include similar one in our samples soon.
Regards,Jordan
the Telerik team
Share feedback and vote for features on our Feedback Portal.
Want some Kendo UI online training - head over to Pluralsight.
Is there a formal Facebook login sample available now?
Thank you,
Hongyi
We just added a sample mobile application with example of Facebook OAuth and Graph API usage - that demonstrates how to read from wall feed and post to it.
You can clone from Sample Projects tab in your dashboard.
In Mist it shall appear in next 24h as sample-facebook-api. (Meanwhile you can clone it in Graphite or directly from from https://github.com/Icenium/sample-facebook-api)
Note that sample uses Chiled Browser Cordova plugin so you need to on real device!
Kind regards,
Jordan
the Telerik team
Share feedback and vote for features on our Feedback Portal.
Want some Kendo UI online training - head over to Pluralsight.
I have a question:
https://github.com/Icenium/sample-facebook-api - does not work on device. Android v 2.3.3
On iPAD2 - working without problem.
Tested with cordova v.2.2.0 and v2.2.4
We're aware of the problem and you can address it by modifying the code in jso.js like so:
Api_default_storage.prototype.getTokens =
function
(provider) {
// log("Get Tokens (" + provider+ ")");
var
tokens = JSON.parse(localStorage.getItem(
"tokens-"
+ provider));
if
(!tokens) tokens = [];
log(
"Token received"
, tokens)
return
tokens;
};
should be:
Api_default_storage.prototype.getTokens =
function
(provider) {
// log("Get Tokens (" + provider+ ")");
var
localTokens = localStorage.getItem(
"tokens-"
+ provider),
tokens = localTokens ? JSON.parse(localTokens) : [];
log(
"Token received"
, tokens)
return
tokens;
};
We're going to fix this in our sample shortly.
Regards,
Steve
the Telerik team
Share feedback and vote for features on our Feedback Portal.
Want some Kendo UI online training - head over to Kendo UI Dojo.
Thanks a lot! Application is working!
Use "Revoke app permissions" button.
Regards,
Steve
Telerik
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
I am trying to have a page that uses the "login button" to login with facebook and go to a new "view" after login is successful. I inserted window.location="#main" after child browser closes. It works fine. However, in my "#main" view, I am trying to post a picture to the user's facebook wall. The function cmdPost is not responding. In fact, I tried putting other buttons in "#main" view too. All of them are not responding. Do you know why this is the case?
Thanks in advance!
The api is great :) But there is a small thing that I can't resolve. When I post some post to my wall, there is a "shared via Icenium Sample". How can I edit that ?
And the other case: when you logIn for a first time, the main message with the permissions shows the Icenium icon and the text again is Icenium Sample. How can I edit that? I want to brand my logo and name :) Is it posibble ? :)
Thanks :)
Best Regards,
Hristo Eftimov :)
Good luck!
I have another small problem :) How can I remove that Success message with the red warning ? I'm using inAppBrowserRef.close(); but that doesn't work iphone :)
Thank you :)
The "success message" is coming from Facebook API, not from Icenium or Cordova. Once you're authenticated successfully, the InAppBrowser is hidden. This works fine in our sample app, our suggestion is to compare the differences with your implementation.
Regards,
Steve
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
Thanks.
Please check our go to blog post about how to use the Facebook Cordova plugin in AppBuilder projects: http://tjvantoll.com/2014/02/06/connecting-appbuilder-projects-to-facebook/
Hope this helps,
Stefan Dobrev
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.
I cannot create clone project from client-browser. Always having this alert:
"An error occured: Failed to create the project in the service."
Is this only for windows client?
Thanks for contacting us.
Currently the 'Clone repository' service is working as expected. For example I cloned https://github.com/tjvantoll/Facebook-Connect.git project successfully.
In order to investigate your problem we will need the steps you are taking when cloning repository?
Thanks.
Regards,
Zdravko
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET. Seats are limited.
I closed the app, and try it again. This time everytime I click login, always go to facebook page with error message:
"The page you requested, cannot be displayed right now. It may be temporarily unavailable....."
But I was success to login with other facebook app. What cause the problem?
Thanks :)
Everytime I click login, it only show alert saying that the app need permission to access my data.
I choose OK, the alert disappears. then nothing happens.
Indeed the app has some difficulties to load the facebook login page on Android HTC 4.0.3 device, but works great on iOS and Nexus 5 Android 4.4.2.
What is your Android device specification?
I suggest taking a look at our sample app which provides another Facebook login approach and it is frequently maintained.
Thanks.
Regards,
Zdravko
Telerik
Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!
Hi Leonard, did you ever manage to get the project to clone?
I've been getting that same error in the in-browser client and am wondering how to fix it.
Using the provided URL (https://github.com/tjvantoll/Facebook-Connect.git) from my previous reply in the in-browser client I was able to successfully clone the app as you can see in this demo.
Please let us know the action you take on your side in order to reproduce the issue if it still remains on your side. Any data like errors provided in the Developer Tools (F12) and a Fiddler log will be appreciated.
The Fiddler log can be obtained using the steps below just consider sending it in a private ticket.
1. Download Fiddler from here and install it.
2. Run Fiddler and go to Tools -> Fiddler Options.
3. On the HTTPS page, verify that Capture HTTPS Connects is enabled.
4. Verify that Decrypt HTTPS traffic is enabled with the ...from all processes option and minimize Fiddler to tray.
5. Try to reproduce the issue and then, continue to step 6.
6. Open Fiddler again, go to File -> Save -> All Sessions, save the archive to disk (a SAZ file).
7. Finally, send us the saz files attached to a private support ticket containing a reference to this thread.
Regards,
Zdravko
Telerik
Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.