I want to integrate custom facebook like button through ACTIONSCRIPT(Flash) programming?
All I could get on the internet is the code to produce facebook Like button using javascript.
I want that same functionality to be provided to my custom button,
I don't want users to redirect intermediate page which having actual facebook Like button.
I tried with intermediate page but it too lengthy for users.they have to click again on that button to share.
Please help me to integrate this functionality.
any help will be great appreciate.
Thanks,
Sandeep
Here's a workaround: you can navigate to the sharing URL from Flash, loaded with the appropriate parameters and opening it on a new window. The following function should work for this purpose:
import flash.net.*;
/**
* Function that allows sharing a page in Facebook
* #param sharedTitle String with the title of the page that you want to share in Facebook
* #param sharedURL String with the full URL that you want to share in Facebook
* #param sharedSummary (Optional) String with a description about your shared content
* #param sharedImageURL (Optional) String with the full URL where the image to display next to your shared post is located
*/
function shareInFacebook(sharedTitle : String, sharedURL : String, sharedSummary : String = null, sharedImageURL : String = null) : void {
var fullURLString = "";
fullURLString += "http://www.facebook.com/sharer.php?s=100";
fullURLString += "&p[title]=" + encodeURIComponent(sharedTitle);
fullURLString += "&p[url]=" + encodeURIComponent(sharedURL);
if (sharedImageURL != null) {
fullURLString += "&p[images][0]=" + encodeURIComponent(sharedImageURL);
}
if (sharedSummary != null) {
fullURLString += "&p[summary]=" + encodeURIComponent(sharedSummary);
}
var theRequest : URLRequest = new URLRequest(fullURLString);
navigateToURL(theRequest, "_blank");
}
Call this function when a button is clicked and you should get a custom Facebook button inside Flash.
More information about how to build a URL to share in Facebook with all parameters (that you can call via Flash:)
Facebook Share doesn't show my description or my thumbnail
And more here as well, including the meta-tags that you can put into your embedding HTML:
How do I customize Facebook's sharer.php
I'm not sure if you are trying on a flash or AdobeAir project but if you are on mobile, here's the solution: https://github.com/myflashlab/facebook-ANE
var like1:LikeBtn = FB.createLikeBtn("https://www.facebook.com/myflashlab", LikeBtn.STYLE_STANDARD, LikeBtn.LINK_TYPE_PAGE, stage);
like1.name = "like" + Math.random();
like1.addEventListener(FBEvent.LIKE_BTN_CREATED, onBtnCreated);
like1.addEventListener(FBEvent.LIKE_BTN_ERROR, onBtnError);
like1.addEventListener(FBEvent.LIKE_BTN_UPDATED, onBtnUpdated);
private function onBtnCreated(e:FBEvent):void
{
var btn:LikeBtn = e.target as LikeBtn;
_btn = btn;
btn.x = Math.random() * 600;
btn.y = Math.random() * 600;
C.log("onBtnCreated, btn.name = " + btn.name);
C.log("width = " + btn.width);
C.log("height = " + btn.height);
btn.update("http://www.myappsnippet.com/", LikeBtn.STYLE_BOX_COUNT, LikeBtn.LINK_TYPE_OPEN_GRAPH);
}
private function onBtnError(e:FBEvent):void
{
var btn:LikeBtn = e.target as LikeBtn;
C.log("e.param = " + e.param);
}
private function onBtnUpdated(e:FBEvent):void
{
var btn:LikeBtn = e.target as LikeBtn;
C.log("onBtnUpdated");
C.log("width = " + btn.width);
C.log("height = " + btn.height);
/*btn.removeEventListener(FBEvent.LIKE_BTN_CREATED, onBtnCreated);
btn.removeEventListener(FBEvent.LIKE_BTN_ERROR, onBtnError);
btn.removeEventListener(FBEvent.LIKE_BTN_UPDATED, onBtnUpdated);
btn.dispose();
btn = null;
C.log("btn.dispose();");*/
}
I've never done this but the consensus appears to be that it's virtually impossible.
If you can, I think your best bet would be to create the button in HTML using the code supplied by facebook and try to integrate that as best you can with your Flash. The following example includes the button in a div positioned above the Flash so it looks like it is directly integrated:
http://www.magichtml.com/tutorial_facebook.html
It might also be worthwhile looking at the ActionScript ExternalInterface class which allows Flash to make JavaScript calls (and vice versa). You could use this to control when the like button is displayed (for example, when your Flash movie has loaded and rendered) for a more seamless integration:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html
Related
I have created a chrome extension to allow users to right-click in a textbox, and insert special characters. This works on many sites such as StackOverflow, but does not work on sites such as Facebook. This is because Facebook is not using a standard text box form control. Instead for each line in a text message, it seems to be using a div > div > span > span construct. Is there a way to create a Chrome extension to target page components such as this?
An portion of my Chrome extension code looks like this:
main.js:
chrome.contextMenus.create({
title: "\u038F",
contexts:["editable"],
onclick: function(info, tab){
chrome.tabs.sendMessage(tab.id, {action: "insertCharacter", character: '\u038F'});
}
});
content.js
chrome.extension.onMessage.addListener(function(request, sender, sendResponse){
var objField = document.activeElement;
if (request.action == "insertCharacter"){
insertAtCursor(objField, request.character);
}
});
function insertAtCursor(sField, sValue){
if (sField.selectionStart || sField.selectionStart == '0'){
var nStart = sField.selectionStart;
var nEnd = sField.selectionEnd;
sField.value = sField.value.substring(0, nStart) + sValue + sField.value.substring(nEnd, sField.value.length);
sField.selectionStart = nStart + sValue.length;
sField.selectionEnd = nStart + sValue.length;
}
else {
sField.value += sValue;
}
}
Is there a more general purpose way I can do this to handle various situations on different sites? If not, is there a way to specifically target Facebook as most of the time myself (and likely others) are going to be using my extension on Facebook. (Of course having it work for email sites such as GMail would be a benefit as well).
In case it helps someone else, this is what I modified my code to based on wOxxOm's suggestion:
chrome.extension.onMessage.addListener(function(request, sender, sendResponse){
if (request.action == "insertCharacter"){
insertAtCursor(request.character);
}
});
function insertAtCursor(sValue){
document.execCommand("insertText", false, sValue);
}
It's much more compact than my original approach and insertText handles the selection aspect automatically.
I'm creating flash game for Facebook. For now after Game Over It opens new tab with share button (suggest share user's game score on wall).
It should pop-up window with share button on the same Game window.
For now my code in ActionScript 3 is:
function gameOver(evt:Event)
{
if (!m_iLives){
var req:URLRequest = new URLRequest();
req.url = "http://www.facebook.com/dialog/feed";
var vars:URLVariables = new URLVariables();
vars.app_id = "0000000000000"; // your application's id
vars.link = "https://www.facebook.com/.......";
vars.picture = "http:/pictureN.png";
vars.name = "Name...!";
vars.caption = "Caption";
vars.description = "My score is " + String(score) + " Try and you!";
vars.redirect_uri = "https://www.url.com";
req.data = vars;
req.method = URLRequestMethod.GET;
navigateToURL(req, "_blank");
}
}
For true pop-ups I always use ExternalInterface. The script below will let you create pop-ups. make sure the ExternalInterface is available. And to customize the size of your pop-up replace the with and height variable with your dimensions
ExternalInterface.call("window.open('" + url + "','PopUpWindow','width=" + width + ",height=" + height + ",toolbar=yes,scrollbars=yes')");
WP8 how to share data from my app to Facebook
or twitter
i want to take screen-shoot of my list-box and then share it on Facebook
i try this code
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "Code Samples";
shareLinkTask.LinkUri = new Uri("https://www.facebook.com/", UriKind.Absolute);
shareLinkTask.Message = "Here are some great code samples for Windows Phone.";
shareLinkTask.Show();
but it doesnot work
You should not use ShareLinkTask for sharing photos. You should use ShareMediaTask. You can more information and how to implement ShareMediaTask by clicking link I provided herewith.
Here's the code:
CameraCaptureTask cameraCaptureTask = new CameraCaptureTask();
//declare it globally
cameraCaptureTask.Completed += cameraCaptureTask_Completed;
//declare it in Constructor
cameraCaptureTask.Show();
//declare it in any method.
For example, button click event. By using this method, you can capture the list box.
//declare this method anywhere in the cs page
void cameraCaptureTask_Completed(object sender, PhotoResult e)
{
if(e.TaskResult == TaskResult.OK)
{
ShowShareMediaTask(e.OriginalFileName);
}
}
void ShowShareMediaTask(string path)
{
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = path;
shareMediaTask.Show();
}
Now, You can easily take screenshot of app's listbox and share it with any of the social networks where user installed on their phone. Cheers.!
I have used this custom Helper in My Razor View.
#Html.Link("OpenewWindow", Constants.Value, new { k = Constants.k, Staff_ID = LoginHelper.GetLoggedInUser() }, new { id = "mytag", target="_blank" })
When I Click on this link it opens me a new window with the Querystrings ConstantValue/Constants?=someValue&Staff_ID=UserLoggedName.
I want to pick the radio button selected value on the form and pass the checked value in QueryString.
So where can I use Jquery function in my custom Helper method to pick the value from the form.
The Custom Helper method takes this kind of aurguments.
public static IHtmlString Link(this HtmlHelper htmlHelper, string linkText, string baseUrl, object query, object htmlAttributes).
You could use javascript to do that. For example you could subscribe to the click event of the link and then open a popup window by appending the new query string parameter:
$(function() {
$('#id_of_link').click(function() {
var url = this.href;
if (url.indexOf('?') > -1) {
url += '&';
} else {
url += '?';
}
// get the value of the radio button
var value = $(':radio[name="name_of_your_radio_groups"]:checked').val();
url += url + 'radiovalue=' + encodeURIComponent(value);
window.open(url, 'newwindow');
// cancel the default action
return false;
});
});
If you don't need to use javascript then a cleaner approach is to use a form instead of a link. This way the value of the selected radio button will automatically be sent.
Desired Behavior: After using the Like button on top of my fan page, I want the user to be sent to the Wall.
Current Behavior: The user remains on the fangate page (custom tab that is set as the default landing page for my fan page).
From what I can tell from another question here, I can't control events that trigger after someone "Likes" my page if they use the button on top of the page.
However, I've been to some fan pages that DO have the behavior I want. I just can't figure out how they did it. Example: StrongMail's Facebook Fan Page
EDIT: Added information - We use an iframe for the Fangate (in case that's relevant)
EDIT: If you want to show certain content instead of going to the wall, make an absolute positioned div on top of your hidden content and hide the div when it's liked.
If you're using C# ASP.Net, I've never had an issue using this technique. You can check for the signed_request and decode using JObject and then redirect as you need.
Check this out: How to decode OAuth 2.0 for Canvas signed_request in C#?
You'll need to download and reference JSON.Net from here: Json.NET
On the page load:
if (Request.Form["signed_request"] != null)
{
var result = (IDictionary)DecodePayload(Request.Form["signed_request"].Split('.')[1]);
JObject liked = JObject.Parse(result["page"].ToString());
if (liked["liked"].ToString().Trim().ToLower() == "true")
{
//do redirection here
}
}
The decode payload function here:
public Dictionary<string, string> DecodePayload(string payload)
{
var encoding = new UTF8Encoding();
var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
var json = encoding.GetString(base64JsonArray);
var jObject = JObject.Parse(json);
var parameters = new Dictionary<string, string>();
parameters.Add("user_id", (string)jObject["user_id"] ?? "");
parameters.Add("oauth_token", (string)jObject["oauth_token"] ?? "");
var expires = ((long?)jObject["expires"] ?? 0);
parameters.Add("expires", expires > 0 ? expires.ToString() : "");
parameters.Add("profile_id", (string)jObject["profile_id"] ?? "");
parameters.Add("page", jObject["page"].ToString() ?? "");
return parameters;
}