FB share plain text without URL link - facebook

I want to share plain text from my web to Facebook without a URL link, I have read the Facebook API, and I found that if I want to share the plain text I must input them to the share page, and Facebook cannot get the text automatically.
Is my conclusion correct?If I am wrong, what should I do? Thanks a lot!

<script>
function fbs_click() {
u = location.href;
t = document.title;
window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
return false; }
</script>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank">Share on Facebook</a>
see : https://spigotdesign.com/text-only-facebook-share-link/

Related

How create a Facebook share button without SDK or custom app id?

I am looking at the latest update to Facebook's share button.
It seems that it's no longer possible to include a share button in a website without including the Facebook javascript SDK, or having a Facebook app somewhere that provides you with an app id?
Share button example 1 uses the Facebook SDK
FB.ui({
method: 'share',
href: 'https://developers.facebook.com/docs/',
}, function(response){});
Share button example 2 uses a custom app id
https://www.facebook.com/dialog/share?
app_id=145634995501895
&display=popup
&href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
&redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer
Question: how to build a plain and simple share button for Facebook with one line of code, that does not require libraries and app id's?
you can use facebook sharer link and a simple popup to do the job
$("#facebookShareLink").on("click",function(){
var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u=http://stackoverflow.com", "pop", "width=600, height=400, scrollbars=no");
return false;
});
It is possible. No need for an FB application for a simple sharing of URL. Create a simple pop up window and use Facebook share dialog.
https://developers.facebook.com/docs/sharing/reference/share-dialog
This is still included in their API as of the moment.
window.open("https://www.facebook.com/sharer/sharer.php?u=http://www.gmanetwork.com/news/", "pop", "width=600, height=400, scrollbars=no");
Create function who will center the pop-up every time.
function openURLInPopup(url, width, height, name) {
if (typeof(width) == "undefined") {
width = 800;
height = 600;
}
if (typeof(height) == "undefined") {
height = 600;
}
popup(url, name || 'window' + Math.floor(Math.random() * 10000 + 1), width, height, 'menubar=0,location=0,toolbar=0,status=0,scrollbars=1');
}
Then your link should look like this
For Twitter:
<a class="btn_twitter" onclick="openURLInPopup('http://twitter.com/home?status=http://www.domain.ro/url.html',600, 400); return false;" href="#" target="_blank">Twitter</a>
For facebook:
<a class="btn_fb" onclick="openURLInPopup('http://www.facebook.com/sharer.php?u=http://www.domain.ro/url.html',600, 400); return false;" href="#" target="_blank">Facebook</a>
For Google
<a class="btn_gplus" onclick="openURLInPopup('https://plus.google.com/share?url=http://www.domain.ro/url.html',600, 400); return false;" href="#">gplus</a>
If you want to add your own (possibly dynamic) text, you can add the quote parameter to the link:
https://www.facebook.com/share.php?u=example.com&quote=YOUR+TEXT+HERE

How can I set a Facebook iframe like button to add current page URL to href on meteor app?

Hy
I want to add facebook iframe like button to my meteor app, but with a dynamic one not static; means, I ll share any page I want not only one page ( one url)
thank's à lot
You can use the query string you are expected to pass to the src of the iframe like this :
<template name="facebookButton">
<iframe allowtransparency="true" frameborder="0" scrolling="no" class="facebook-button"
src="https://www.facebook.com/plugins/like.php?{{queryString}}">
</iframe>
</template>
We use a simple helper to build the query string, it will be reactive and we can feed it with the current url (location.href).
Template.facebookButton.helpers({
queryString:function(){
var parameters={
href:encodeURIComponent(location.href),
send:"false",
layout:"box_count",
show_faces:"false",
action:"like",
font:"arial",
colorscheme:"light"
};
var pairs=_.pairs(parameters);
var pairsJoined=_.map(pairs,function(pair){
return pair.join("=");
});
return pairsJoined.join("&");
}
});
EDIT : forgot to URI encode the href param.

How to cancel redirection of page with click?

I have a redirection code (working fine) in several pages as follow :
<meta http-equiv="refresh" content ="42; url=http://my url.html#">
But i want the automatic redirection to be cancelled or delayed if the user clicks in any point of the page.
What code should i use ?
Thanks
Here is the code for click on page anywhere:
<script>
$('html').click(function () {
alert("ok"); // Do whatever you want here, just replace. Since i dont know your code. So i can help you till this point.
});
</script>
Remove you <meta http-equiv="refresh"> from Documents <head></head>
Insert a simple JS-Timer and use window.location to refer the User after the Page loaded.
var timeVar = setInterval(function () {myTimer()}, 1000);
var t = 9;
function myTimer() {
if (t>0) {
document.getElementById("timer").innerHTML = t;
t--;
}
else { window.location = 'what/ever/you/are/workingon.html'; }
}
function StopFunction() { clearInterval(timeVar); }
<p>Redirecting in <span id="timer" style="font-weight: bold;">10</span>Seconds.</p>
<p onclick="StopFunction();" style="cursor: pointer; ">Cancel!</p>
The User will load your page and when not canceling the Timer be redirected to the Page you defined. If stopping the Timer the user wont be redirected and stay on the Page. br
Try just to empty cache, it should work.

Fake HTML URL address when mouse is over a form

let's say that I have the following form:
<form method="post" action="" autocomplete="off"><input name="checking2" type="submit" value="Name" class="ssd"></form>
When a user submits the form this PHP code takes place:
if(isset($_POST['checking2'])){
$xmla = new SimpleXMLElement('passwords/' . views . '.xml', 0, true);
$plus = $xmla->goodx;
$result = $plus + 1;
$xmla->goodx = $result;
$xmla->asXML('passwords/' . views . '.xml');
header( 'Location: http://google.com' ) ;
}
And the following CSS to design the form: code:
.ssd {
border: none;
background-color: transparent;
padding: 0;
cursor: pointer;
font-size:89%;
display:inline;
text-decoration: underline;
color: #00c;
}
Now, every time that the user clicks on the form he is being redirected in return to google. The PHP code is supposed to add +1 to a xml file's value(It works) every time that someone submits the form. My problem is, that whenever someone places his mouse over the form's value, the URL that he sees is the URL address of the current page he is currently on, Not the URL he will be actually redirected to - Google. I am trying to fake the URL address, so instead of seeing the current page URL address(which is action=""), he will see the URL address of google. And no, do not suggest to just place the URL address of google in "action=", because then the PHP data does not being updated properly for some reason whenever I do that. Any help will be appreciated.
In case I got you right, you want to change the forms action property, don't you?
If so, use this little javascript code:
<script>
function fake_action(){
document.forms["myform"].action="http://example.com";
document.forms["myform"].submit();
}
</script>
<form id="myform" action="http://google.com">
<input type="text" placeholder="placehold.it"/>
<input type="button" value="send" onclick="fake_action();"/>
</form>
Just a quick explenation: I have replaced the submit button with a standard button and specified the fake_action(); function as onclick event handler for it. The fake_action function just change the form's action and submit it afterwards. So you can do your stuff without any problem.
(You should just check for GET / POST Parameters at the page load and eventually send them on to the second page after you received them on the first one ;) )

Problem in facebook share functionality

I have a facebook iframe application where i have provided a share functionality. I am using this code :
<script>
function fbs_click()
{
u='<?php echo $shareURL;?>';
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
<style>
html .fb_share_button {
display: -moz-inline-block; display:inline-block;
padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea;
background:url(http://b.static.ak.fbcdn.net/rsrc.php/z39E0/hash/ya8q506x.gif)
no-repeat top right;
}
html .fb_share_button:hover {
color:#b5b8d3; border-color:#295582; background:#3b5998
url(http://b.static.ak.fbcdn.net/rsrc.php/z39E0/hash/ya8q506x.gif)
no-repeat top right; text-decoration:none;
}
</style>
Share
The problem i am facing is that if i pass u to my site url then inside share box title is properly displayed but when posted to my profile, clicking on the link redirects me to outside of my facebook application which i don't want i want it to remain inside facebook page.
However if i change u parameter to something like http://apps.facebook.com/app/ then inside share box the title is showing apps.facebook.com and when posted on my profile, clicking on it redirects me inside the facebook application but onto a new tab.
I just want the title should be set according to the value passed and if i click on it on my profile page it should remain inside facebook.
I have found a solution to this problem you have to change the parameters in the window.open and pass the value as urlencode(i have done in php)
I am attaching the changed code:
1)
<?php
$title=urlencode('Facebook Share Platform');
$image=urlencode('imagepath');
$summary=urlencode('Check This Out');
$url=urlencode('http://apps.facebook.com/yourapplication');
?>
2)
window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[summary]=<?php echo $summary;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=626,height=436');
Hope this helps to others who are facing same issue.
Thanks
def fb_share_knob opts={}
opts.each { |k,v| opts[k] = CGI.escape(v) if v.present? }
sharer_url = "http://www.facebook.com/sharer.php?s=100&p[url]=#{ opts[:url] }&p[title]=#{ opts[:title] }&p[summary]=#{ opts[:summary] }&p[images][0]=#{ opts[:image] }"
<<-FB_SHARE_LINK
<script type="text/javascript">
function fbs_click() {
window.open('#{ sharer_url }','sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
Share on Facebook
FB_SHARE_LINK
end
Ruby code. Image load problem: if the image you'd like to share is on your test server make sure it's accessible from outside of your firewall