Url get truncated while posting in facebook - c#

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.

Related

Facebook authentication on Nopcommerce platform

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.

How to import facebook account posts in asp.net page

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.

Need simple Twitter API v1.1 example to show timeline using jQuery or C# ASP.NET

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

#Html.PasswordFor dont let to paste the password

I use this code in my login panel in MVC3:
#Html.PasswordFor( m => m.Password, new { maxlength = 10 } )
I want to do that, somebody cannot to PASTE any password to PasswordFor.
(To enter password ONLY with typing)
what must i do?
You probably shouldn't do as it completely sucks from user's perspective but if you want your users to hate you, you could do this:
$('#Password').bind('paste', function(e) {
e.preventDefault();
});​
Something like:
var pw = document.getElementById("Password");
pw.addEventListener("paste", function(event)
{
event.preventDefault();
}
... with equivalent event listening and default prevention for IE etc.
jQuery:
$("#Password").bind("paste", function(event)
{
event.preventDefault();
});
Neither will work on Opera.
But then, you shouldn't be doing it in any event. My personal way of "pasting" passwords is way more secure than you tampering with my browser's default user experience. And you're messing with my method, which is likely to make me pick a less secure password specifically for your site. Or not use it.
You can use like this
$(document).ready(function(){
$('#Password').live("paste",function(e) {
e.preventDefault();
});
});

Facebook registration protocol

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

Categories

Resources