How to create a share button in AS3
I was wondering if anyone knew a good way of creating an 开发者_如何学运维AS3 Facebook share button? I need to be able to customize the title, description and picture. Thanks!
Look: http://www.facebook.com/facebook-widgets/share.php
http://www.facebook.com/sharer.php?u=<url>&t=<title>
In Flash:
import flash.net.navigateToURL;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
share_btn.addEventListener(MouseEvent.CLICK, shareClickHandler);
function shareClickHandler(evt:MouseEvent):void
{
var varsShare:URLVariables = new URLVariables();
varsShare.u = 'http://domain.com/pageN.html';
varsShare.t = 'Title Page';
var urlFacebookShare:URLRequest = new URLRequest('http://www.facebook.com/sharer.php');
urlFacebookShare.data = varsShare;
urlFacebookShare.method = URLRequestMethod.GET;
navigateToURL(urlFacebookShare, '_blank');
}
In order to use a picture add the following Metatags:
<meta name="title" content="my title" />
<meta name="description" content="my description" />
<link rel="image_src" href="images/thumbnail_image.jpg" />
For more info: https://developers.facebook.com/docs/opengraph/
here you go:
redirect_uri is required (and must redirect to your application site as defined in the facebook application settings page)
var req:URLRequest = new URLRequest();
req.url = "http://www.facebook.com/dialog/feed";
var vars:URLVariables = new URLVariables();
vars.app_id = "000000000000"; // your application's id
vars.link = "http://YourSite.com";
vars.picture = "https://www.google.com/intl/en_com/images/srpr/logo3w.png";
vars.name = "name name";
vars.caption = "caption caption caption";
vars.description = "description description description";
vars.message = "message message message message message";
vars.redirect_uri = "http://YourSite.com";
req.data = vars;
req.method = URLRequestMethod.GET;
navigateToURL(req, "_blank");
It depends on what you wish to share.
You can use the following url in a button:
http://www.facebook.com/share.php?u=http://www.mypage.com/
which will pop up a page prompting the user to log in and share whatever they want to share.
Could you be more precise as to what you want to allow your users to share?
精彩评论