i am in my way to apply my website users to add comment using face book in my account in my website . i have created my app using this link
and then tried the below code
<div id="fb-root" ></div>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'my API ID',
status: true,
xfbml: true
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
but there is no result and nothing appears to he screen???
any help
You're missing fairly considerable amount of code still... The code you posted will just bring in the Facebook SDK.
Have a look at my comment in this thread which will illustrate how to properly import the SDK.
Once you have it imported, you have to define the HTML in your page to actually place the comment box on the page as well as some other stuff for how it behaves. You're going to want to check out (and sign up for) the Facebook developers page, which offers some useful, yet seriously lacking, information on how to load comment blocks, like buttons and how to use OpenGraph stuff. I'd give you the link there, but corporate policy prevents me from accessing Facebook.
Related
I don't understand the documentation of Nopcommerce.
it seems (in the documentation) that it should be very easy steps - http://docs.nopcommerce.com/display/nc/Facebook+Authentication
I have created Facebook app,
I copied and pasted the App ID/API Key
and the App Secret to the nopcommerce admin section : "Configure - Facebook Authentication".
I have put this block inside the body tag of the root:
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'xxxxxxxxxxxxxx',
cookie: true,
xfbml: true,
version: 'v2.2'
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
NOW WHAT ???
Where and how should i put the login button?
Facebook authentication doesn't use the JavaScript api. It handles it server side. Follow the steps from the page you linked and those outlined here http://docs.nopcommerce.com/display/nc/External+Authentication++Methods to enable it.
If you still can't see the login with Facebook button, maybe your template its not rendering it. Check the login views from the default theme for more information.
From the external authentication methods configuration screen, make sure you click "edit" then check the box under: "Is Active". Save and you're good to go.
With Twitter turning off the API 1.0 faucet on 6/11/2013, we have several sites that now fail to display timelines. I've been looking for an "If you did that, now do this" example. Here was Twitter's announcement.
https://dev.twitter.com/blog/api-v1-is-retired
Here is what we were originally doing to show the Twitter timeline via API 1.0.
<div id="twitter">
<ul id="twitter_update_list"></ul>
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline/companytwitterhandle.json?callback=twitterCallback2&count=1"></script>
<div style="float:left;">#companytwitterhandle | </div>
<div class="twitterimg"> </div>
</div>
Initially I tried changing the version in the JavaScript reference URL like so, which did not work.
<script type="text/javascript" src="http://api.twitter.com/1.1/statuses/user_timeline/companytwitterhandle.json?callback=twitterCallback2&count=1"></script>
Then I looked at the Twitter API documentation (https://dev.twitter.com/docs/api/1.1/overview) which lacks a clear transition example. I don't have 4 or 5 hours to delve into that, or into this disheveled FAQ (https://dev.twitter.com/docs/faq#17750).
Then I found this API documentation regarding the user timeline. So I changed the URL again as shown below.
https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
<script type="text/javascript" src="https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=companytwitterhandle&count=1"></script>
That did not work.
Using jQuery or C# ASP.NET MVC, how can I transition that interface from Twitter API 1.0 to Twitter API 1.1? My first preference would be for a browser client side implementation if that is possible. Please include a code example. Thanks.
This is how I did this:
Please see my question and answer here:
Authenticate and request a user's timeline with Twitter API 1.1 oAuth
Use the above solution and render the json back to the page, store it in a variable called json.
Put a reference to jQuery and the twitter-text js library;
https://github.com/twitter/twitter-text-js
Add a div with an id or results to your aspx:
<div id="results"></div>
You can render the content with the following javascript:
for (var i = 0; i < json.length; i++) {
$("#results").append('<div class="tweet"><p><span><strong> - ' + json[i].created_at.substring(0, 16) + '</span></strong></span><br/>' + twttr.txt.autoLink(json[i].text) + '</p>');
try {
for (var j = 0; j < json[i].entities.media.length; j++) {
$("#results").append('<img src="' + json[i].entities.media[j].media_url + ':thumb" />');
}
} catch(e) {
}
}
Okay, I received an answer from a colleague who had to make a similar change at my company. Here is the coded solution. He received this from a company we contracted to build a new interface for us with a Twitter timeline.
<a class="twitter-timeline" href="https://twitter.com/companytwitterhandle" data-widget-id="18DigitMagicNumber" data-chrome="nofooter transparent noscrollbar noheader noborders" data-tweet-limit="1" >Tweets by ##companytwitterhandle</a>
<script>!function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https'; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = p + "://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); } }(document, "script", "twitter-wjs");</script>
You will see in the data-widget-id attribute 18DigitMagicNumber. That number is apparently tied to our Twitter handle or our company. I don't know how that gets generated.
As indicated, a contracted company wrote that code for us, so I won't try to explain what it's all doing.
I cut and pasted this from one site into an unrelated site and it worked immediately. The only thing I changed was to remove the actual company handle and data-widget-id, and to replace the single # with ## to escape it in MVC.
Hopefully this will help some of you who are also migrating to Twitter 1.1. Thanks.
Create a JavaScript only solution that just works out the box to get Twitter posts on your site without using new API - styling is left up to you - can now specify number of tweets too:
http://goo.gl/JinwJ
I am using Facebook like in my web page. The url to be posted is having query string like
http://test.something.in:302/sample.aspx?id=54
but it is truncated while posted in facebook and the url became
http://test.something.in:302/sample.aspx.
Can anyone please help me to solve this?
<body>
<div id="fb-root"></div>
window.fbAsyncInit = function () {
FB.init({
appId: '451971411518111',
status: true,
cookie: true,
xfbml: true
});
};
(function (d, debug) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
<form id="form1" runat="server">
<div class="fb-like" data-href="http%3A%2F%2Ftest.something.in%3A302%2Fsample.aspx%3FId%3D54" data-send="false" data-width="450" data-show-faces="true"></div>
</form>
If I understand your question correctly, you have to encode the link when you pass it to the Facebook Direct FB URL.
A good online encoder can be found at W3Schools:
http://www.w3schools.com/tags/ref_urlencode.asp
The JavaScript function http://www.w3schools.com/jsref/jsref_encodeuri.asp is also good for encoding your URLs on the fly, though I have no clue about what function to use in C# (Don't ask me about C# as I have never coding one character on C#. I don't even know if it has functions. :P)
For example, the URL you provided would be encoded something like this:
http%3A%2F%2Ftest.something.in%3A302%2Fsample.aspx%3Fid%3D54
Tell me if this works.
BTW this question is basically a duplicate of Facebook URL truncated. Try to avoid duplicates in the future. They can lead to closures of your question, a lot of downvotes (which I was nice enough not to do) and even a temporary ban. Don't worry about it now, just for the future.
I'm using C# in MonoDevelop with the Graph API to interact with users facebook pages.
I've become thoroughly confused though.
Are these the correct steps?
create facebook app Here : http://developers.facebook.com/
programmaticly get access token using app ID and app Secret.
If so how do I go from this to posting to users walls?
I've done lots of research but have been unable to find anything particularly useful.
I've tried using this ASP.NET Post to Facebook Wall but Nothing ever appears on the wall.
Is there a tutorial or something that can take me through the process nice and slow?
All help or pointers appreciated.
As stated i'm working with unity3d, c# in mono and the facebook graph api.
[Edit] I'd like it to work on android.
Use the C# Facebook library. There is a sample project called facebook-aspnet-sample which shows you authentication and login. Also, have a look at this tutorial page which deals with how to connect from a Unity3d game to Facebook. The tut is short but the demo project download is useful.
There are also plugins for sale that enable Facebook access from Unity3d.
after your have your FB app ready, indeed, you need to get a token. However, token is always requested in the context of a USER - and therefore user should authenticated on the website. That means that Facebook login dialog should be displayed - which will ask user if he indeed trusts the application. There are different ways to do this - here is the generic page about FB authentication: https://developers.facebook.com/docs/authentication/, and this one explains how to do this in Android: https://developers.facebook.com/docs/mobile/android/sso/
if you want to go with JavaScript authentication (which I personally use in MVC3 project), here is a little bit modified example from https://developers.facebook.com/docs/authentication/client-side/ which does this. Remember to change app id and permissions to the ones you need.
<div id="fb-root"></div>
<script>
// Load the SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
} (document));
// Init the SDK upon load
window.fbAsyncInit = function () {
FB.init({
appId: '#EventController.FB_APP_ID', // App ID
channelUrl: '//' + window.location.hostname + '/channel.htm', // Path to your Channel File
status: false, // check login status
cookie: false, // enable cookies to allow the server to access the session
xfbml: false // parse XFBML
});
// listen for and handle auth.statusChange events
FB.Event.subscribe('auth.statusChange', function (response) {
if (response.authResponse) {
// user has auth'd your app and is logged into Facebook
FB.api('/me', function (me) {
// get info about the user, for example
})
//document.getElementById('auth-loggedout').style.display = 'none';
} else {
// user has not auth'd your app, or is not logged into Facebook
//document.getElementById('auth-loggedout').style.display = 'block';
}
});
// respond to clicks on the login and logout links
document.getElementById('auth-loginlink').addEventListener('click', function () {
FB.login(function (response) {
// handle the response
if (response.authResponse != null) {
// HERE IS THE TOKEN YOU CAN USE
var token = response.authResponse.accessToken;
} else {
}
// AND THESE ARE THE PERMISSIONS YOU WANT YOUR APP TO REQUEST
}, { scope: 'manage_pages,publish_stream' });
});
};
</script>
One catch here - your FB app should have your website URL (even if it is http://localhost/) in App -> Settings -> Website URL field. Also you should put channel.htm file into the root of your website with one line of code in it:
<script src="//connect.facebook.net/en_US/all.js">
I am making a marketing tool that is required to register facebook accounts using web requests. I have been trying to understand the protocol but I always end up with a "Sorry there is something went rong" page. Any explanations are appreciated =].
Regards
edit: I am trying to let the user to register on facebook through my application. He should input the required fields (names,birthday,email) and the application should do the signup process for him after he solves the captcha that will be fetched from facebook. It's not a spam attempt, Don't bother saying you won't answer because it's a spam attempt. If you think so, just don't answer.
edit: I don't want to use any WebBrowser controls, I need it to be through HTTP Requests.
edit: I try to imitate requests sent to facebook from my computer using fiddler, I believe I imitated everything that facebook website does. Though I still getting "Sorry something went wrong" page.
You have several API to to that. I recommend that you use the last one, the graph API. Then you have several SDK, I know PHP and Javascript SDK.
In javascript, with jQuery you can do
<body>
<div>
<button id="login">Login</button>
<button id="logout">Logout</button>
<button id="disconnect">Disconnect</button>
</div>
<div id="user-info"></div>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// initialize the library with the API key
FB.init({ apiKey: 'YOUR_API_KEY' });
// fetch the status on load
FB.getLoginStatus(handleSessionResponse);
$('#login').bind('click', function() {
FB.login(handleSessionResponse, {
// here you specify the perms your application requires
perms:'publish_stream, offline_access, manage_pages, read_stream'
});
});
$('#logout').bind('click', function() {
FB.logout(handleSessionResponse);
});
$('#disconnect').bind('click', function() {
FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
clearDisplay();
});
});
// no user, clear display
function clearDisplay() {
$('#user-info').hide('fast');
}
// handle a session response from any of the auth related calls
function handleSessionResponse(response) {
// if we dont have a session, just hide the user info
if (!response.session) {
clearDisplay();
return;
}
// if we have a session, query for the user's profile picture and name
FB.api('/me/accounts', function(response) {
$('#user-info').html(JSON.stringify(response));
});
}
</script>
</body>
This example is taken from the documentation of the JavaScript SDK. You need to get you API_KEY from the facebook developper page http://www.facebook.com/developers/apps.php