开发者

Facebook button for Ajax Pages, how to implement and verify that it works

开发者 https://www.devze.com 2023-03-28 13:34 出处:网络
I wanted to know how can I use Facebook Like button on my Ajax web application, that will capture changes in the Open Graph tags for both the og:title and the og:url. I already createda Facebook app a

I wanted to know how can I use Facebook Like button on my Ajax web application, that will capture changes in the Open Graph tags for both the og:title and the og:url. I already created a Facebook app and got an API ID.

What I want to know is the code that I need to put on my website i开发者_如何学Pythonn order for Facebook to capture the changes that I've made to the meta tags which contains that title and url information (ie. og:title, og:url).

I followed the instructions on Facebook without success. Furthermore, I want to know how can I locally test the Like button to see that it grabs the data from the Open Graph tags properly.

Also worth mentioning that I've a JQuery code that automatically alters the Open Graph meta tags to include the relevant information for the current Ajax changed page.

Thanks.


You will need to have a separate url for each different page that you want to allow people to like. I would recommend actually pointing the like button to the physical pages you're trying to return via the og:url tag. To refresh the data that Facebook stores about a given url, pass that url into the linter at http://developers.facebook.com/tools/lint.


i created a rotator file for facebook share on my dynamic ajax website.

rotator.asp code sample:

<html>
<% lang=request("lang")
   id=request("id")

   ..some sql to get data...
   ogTitle=....
   ogImage=....
   originalUrl=....

%>
<head>
<meta property="og:title" content="<%=ogTitle%>" />
<meta property="og:image" content="<%=ogImage%>" />
.....
......
<meta http-equiv="refresh" content="0; url=<%=origialUrl%>" />
//dont use redirect.. facebook dont allow 302...
</head>
<body></body>
</html>

for example xxx.com/#!/en/153 page will share xxx.com/rotator.asp?lang=en&id=153

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号