I am trying to post a Action to the Facebook Timeline using the JS API
FB.api('/me/application:action_type' + '?opject_type='+document.location.href,'post',
function(response) {
if (!response || response.error) {
alert("error");
} else {
alert("success");
}
});
Posting works quite well and the API returns no error. A new activity appears at the Timeline but only as a small text within the "recent activities" box which looks like this:
What could be the problem if the action is not displayed like in the Attachment Preview of the Action Type Settings? Which look like this:
I have linked all the properties from the Object Type and tested my Object URL with the Facebook Debugging Tool and it looks like all the attributes can be parsed correctly by the Facebook scraper.
I also defined a aggregation layout for the action type. So what can be the reason that no Attachment is displayed?
You can see a single action attachment layout on your timeline by setting "Shown on timeline" instead of "Allowed on timeline", but by default you will never see a single action on the timeline. You will see the single action attachment in the ticker (and maybe in the news stream).
If the user doesn't change the display mode You will only see aggregations on a timeline
I also reported this issue as a bug to facebook. Their reply was that this behavior is by design and the attachment layout only appears in the activity log or when multiple activities have been posted to a users timeline.
Have you set the object parameters on your web page? For instance:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# app: http://ogp.me/ns/fb/app#">
<meta property="fb:app_id" content="123" />
<meta property="og:type" content="app:action" />
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:title" content="Testing Title" />
<meta property="og:description" content="testing Description" />
<meta property="og:image" content="http.example.com/image.jpg" />
You will need to get the correct code off the Facebook Developers website but it is essential that you create your object in order for Facebook to get the parameters from your webpage.
You can test it by simply going into aggregations->preview->add-action, and in event, just paste the webpage. You will see instantly if it works.
Related
My coding as below:
<!DOCTYPE>
<html>
<head>
<script src="https://connect.facebook.net/en_US/sdk.js"></script>
<meta property="fb:app_id" content="1665615247095212" />
<meta property="og:type" content="heppiheppi:shares" />
<meta property="og:url" content="http://mywebsite.com" />
<meta property="og:title" content="Walk-in" />
<meta property="og:image" content="http://mywebsite.com/images/intro.jpg" />
<meta property="og:description" content="Bring more customers" />
</head>
<body style='padding:0;margin:0;'>
<div id="fb-root"></div>
<script>
FB.init({
appId : '1665615247095212',
xfbml : true,
version : 'v2.7'
});
function LaunchDialog(){
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object:'http://mywebsite.com',
})
},
function(response) {
if (response && !response.error_message) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
});
}
</script>
Share now
</body>
</html>
If test on desktop browser, click "Share now", prompt the share dialog, click cancel/X, it will displays 'Error while posting.'
If test on mobile browser, click "Share now", prompt the share dialog, click cancel/X, it will displays 'Posting completed.'
Does anyone has any clue on this issue?
You set og:type to "heppiheppi:shares", have you created this Object type in your App !?? If it's not, set it back to "website".
Facebook team has confirmed this as a bug and assign this to the relevant team to investigate further.
Update from Facebook:
The sharing team have investigated in detail and determined that the discrepancy is due to the different code paths on our side for the mobile and desktop version of the dialog
When you receive a post ID or error message in the response object, it should be as documented if the user has logged into your app and/or has granted publish_actions permission
For all other cases, we don't document what the response will be, and the discrepancy you're encountering is that sometimes you receive an empty 'response' object and other times there's no response object at all
At this time it's not planned to make any changes to resolve this, and you cannot use the lack of response from the dialog to make any determination about whether a post was created
Apologies for the delay in getting a definite answer here, but you should assume that the current behaviour will remain in the short to medium term;
If long term changes are made, I think it's more likely that the response will be removed completely as that would be consistent with the other changes in this area to prevent share gating and other incentivization of users posts.
I am trying to tweet with image using javascript.I read about cards, and put the following on page i am sharing:
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="http://203.110.93.244/">
<meta name="twitter:creator" content="#SarahMaslinNir">
<meta name="twitter:title" content="Parade of Fans for Houston’s Funeral">
<meta name="twitter:description" content="NEWARK - The guest list and parade of limousines witproject here.">
<meta name="twitter:image" content="http://www.promon.in/media/images/products/2015/09/listing_image_vsRFOqw.jpg">
then i use this javascript to tweet:
twttr.widgets.createShareButton(
'http://203.110.93.244/offers/eat-n-drink/Delhi-greater-kailash-rara-avis/81/',
document.getElementById('twitter-btn'),
{
text: '#HelloWorld',
});
Problem is, I am not getting any image thumbnail.
Please guide me towards a viable solution.
Thanks.
Something as follows works for me. It opens a window whenever the user clicks a button... It sends the "URL" of the source page, "via" which is your twitter username, and "text" which is whatever message you want to appear in there. Note that the amount of text is limited and if too long Twitter silently eliminate part of the data.
The page URL with the image must appear first. You can test the validity of the page here: https://cards-dev.twitter.com/validator
jQuery("#twitter-share-button").click(function(e)
{
e.preventDefault();
var uri = "http://203.110.93.244/offers/eat-n-drink/Delhi-greater-kailash-rara-avis/81/";
var tweet = "https://twitter.com/intent/tweet?url="
+ encodeURI(uri)
+ "&via=yourtwittername&text="
+ encodeURI(uri)
+ encodeURI(" #your-hash-tag ")
+ encodeURI("some more text here");
window.open(tweet, "Share on Twitter");
});
I am trying to parse a webpage using jQuery. This is my code:
$.get(u, function(data)
{
console.log(data);
$(data).find('meta').each(function()
{
console.log($(this).text());
//alert($(this).text());
alert($(this).attr('content'));
console.log($(this).attr('content'));
});
});
The page source is here.
There are many meta tags in this page but its only able to parse 6 of them namely :
<meta property="og:type" content="website" />
<meta property="og:title" content="Affect and Engagement in Game-BasedLearning Environments" />
<meta property="og:description" content="The link between affect and student learning has been the subject of increasing attention in recent years. Affective states such as flow and curiosity tend to have positive correlations with learning while negative states such as boredom and frustrat..."/>
<meta property="og:url" content="http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6645369" />
<meta property="og:image" content="http://ieeexplore.ieee.org/assets/img/logo-ieee-200x200.png" />
<meta property="og:site_name" content="IEEE Xplore" />
<meta property="fb:app_id" content="179657148834307" />
What am I doing wrong?
jQuery will skip all meta-Tags which do not have closing brackets.
You therefore would be forced to parse the response using a regular expression, but this is in fact ugly.
It's very sad, that we still live in a world where there is such HTML out there.
If you really want to go that path, you could do some thing like this
data = data.replace(/(<meta.*[^\/])>/g, "$1/>");
before doing the "find" on it.
You must append the response to an element and then get the meta.
$(data).appendTo("#test");
var m = $('#test').find('meta');
alert(m.length);
$('#test').html(''); // delete content
Example: http://jsfiddle.net/B4ATz/
I am using JavaScript sdk for one of my Facebook canvas game application. I am trying to implement custom story share dialog to post story on user wall.
The information available on developer site is unclear and limited.The bellow code is for sharing custom story using open grap API. Bellow code is available on Facebook developer site link provided(https://developers.facebook.com/docs/sharing/reference/share-dialog). The Facebook provided code is working fine as its using predefined action_type.
FB.ui({
method: 'share_open_graph',
action_type: 'og.likes',
action_properties: JSON.stringify({
object:'https://developers.facebook.com/docs/',
})
}, function(response){});
I have create an object(cricket) and action(play) for custom story on FB Developer console App's Open Graph tab.i have created a self hosted Object(html page) called cricket.html.Bellow is the content or my html page.i verified the html page on Open Graph Object Debugger.Graph Object Debugger showing me all the information, what i have given with no errors or warnings .
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta property="fb:app_id" content="*************" />
<meta property="og:type" content="appnamespace:cricket" />
<meta property="og:title" content="App for u" />
<meta property="og:url" content="https://example.com/appnamespace/cricket.html" />
<meta property="og:description" content="Find me on facebook for u" />
<meta property="og:image" content="https://example.com/appnamespace/image/any_time_share.png" />
</head>
<body>
</body>
</html>
Bellow is my code where I am replacing:-
og.likes ---to--->appnamespace:play("play"is my action).
Is i am doing any thing wrong here ? please let me know.
function customshare()
{
FB.ui({
method: 'share_open_graph',
action_type: 'appnamespace:play',
action_properties: JSON.stringify(
{
object:'https://example.com/appnamespace/cricket.html',
})
},
function(response){});
}
However i am getting the below error while executing the FB.ui method: 'share_open_graph' for custom share.
I got my problem solved by simple changing this:-
object:'https://example.com/appnamespace/cricket.html',
To
cricket:'https://example.com/appnamespace/cricket.html',
You need to mention the url in url field of object i guess then only it will work and cricket field is missing as seen from your error message
i want to change title in every page of my code but when i view source code i still see the old title.
here is my code:
window.onload = function (){
setProductMeta();
}
function setProductMeta(){
var des = document.getElementById("description").setAttribute("content","dynamic meta description");
document.getElementById("keywords").setAttribute("content","dynamic meta keywords");
document.title = "Point of Sale System";
}
and this meta tage above
<title>Welcome to Atmostphere Technology</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta id="title" name="title" content="Welcome to Atmostphere Technology" />
<meta id="description" name="description" content="atmos is best service in cambodia" />
<meta id="keywords" name="keywords" content="atmos is best service in cambodia" />
The server delivers the source code to the browser.
The browser converts the markup in to a DOM.
Then JavaScript runs and any DOM manipulation you perform is performed. It never touches the source code.
While it is sometimes useful to change the title with JavaScript (e.g. Facebook do it to indicate the number of alerts since the page was last interacted with), almost everything that consumes meta data does not execute JavaScript. If you want to change something fundamental about the page, do it in the source code, not with client side programming.