Share image on Facebook - facebook

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.!

Related

Sharing screenshot with text to facebook unity

I'm trying to give the user the possibility to post a screenshot of his game on facebook with the dowload link of the game.
I've looked a bit and it seemed it would be possible with FB.API, but I can't manage to make it work.
Aparently you need a permission but I can't to find which permission and how to give it.
I'm using unity 2020.3.21f1
Here is what I'm doing for now
public void ShareScreenShot(Texture2D screenShot)
{
byte[] encodedScreenShot = screenShot.EncodeToPNG();
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", encodedScreenShot, "ScreenShot.png");
wwwForm.AddField("message", "Venez me défier : https://randomlink.blablabla");
FB.API("me/photos", HttpMethod.POST, ShareScreenShotCallback, wwwForm);
}
void ShareScreenShotCallback(IResult result)
{
if (result.Error != null)
{
Debug.Log(result.Error);
}
else
{
Debug.Log("sharing success");
}
}
If anyone of you knows how it can be done, it would be of great help, thanks
I suppose you need to login to facebook with custom permissions, because the default one only allows you to send invitations to choosen friends.
https://developers.facebook.com/docs/unity/reference/current/FB.LogInWithPublishPermissions/

How to add google+ share callback in Gigya Wordpress plugin?

I am currently using Gigya wordpress plugin to implement the share bar in Wordpress but I need to be able to track the share event and I am not using Google Analytic. Any idea how I can add a callback in this plugin to enable tracking? The reason I need to use a callback is because google plus share is in an iframe and I can't bind the click event.
I've read this documentation but this is using the Gigya api which is different than the wordpress plug. I tried to use this piece of code and it is not doing anything.
// onSendDone - event handler method, called after Gigya finishes the sharing process
// Reports the event to your Analytics provider
function onSendDone(event) {
console.log('click');
if(event.providers) {
var providers = event.providers.split(",");
for(i = 0; i < providers.length; i++) {
var provider = providers[i];
// Report the event to your Analytics provider
//waTrackPlusOne_vote(provider);
console.log('pass in ' + provider);
}
}
}
var ua = new gigya.services.socialize.UserAction();
var currentURL = window.location.href;
var $currentTitle = $j('title').text();
ua.setLinkBack(currentURL);
ua.setTitle($currentTitle);
// Define Share Bar plugin's Parameters
var shareBarParams ={
userAction:ua,
shareButtons: "google-plusone",
containerID: '.gig-button-container-google-plusone', // location of the Share Bar plugin,
onSendDone: onSendDone // onSendDone method is called after Gigya finishes the publishing process.
}
// Load Share Bar plugin
gigya.services.socialize.showShareBarUI(shareBarParams);
I have just faced the same problem, here it's how I've done it.
At some points when setting up the Gigya Share Button you will have to declare a variable called "shareParams", invoked in gigya.services.socialize.showShareUI(shareParams).
Just add 'onSendDone' : yourFunctionName to the shareParams object.
Example:
var shareParams = {
'userAction' : {0},
'onSendDone' : myNamespace.GigyaSendDone
}
gigya.services.socialize.showShareUI(shareParams);
When the sharing is successfully completed, this Javascript action will be invoked.
So thanks to Emanuele Ciriachi, I found the js api code in the plugin. Once modified it, I think this will resolve my issue.

Page redirection in sharepoint 2010 webpart(sandboxed solution) using c# code is it possible?

I am using a sandboxed solution (sharepoint 2010 project is on office 365 hence using sandboxed solution) and want to go from one page to another on a button click event. This is achieved by javascript but the operations in the click event are not being performed.
For example, I assign the javascript on page load to the desired event then the event performs the redirection without going into the code which is inside the event.
The javascript used for redirection is :
string redirectURL = "http://ksreejit:32512/sites/SplTeam/Pages/QuizMasterDashboard.aspx";
btnCancel.Attributes.Add("OnClick", "javascript:{window.location='" + redirectURL + "';return false;}");
And the event code is:
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (ViewState["QuestionID"].ToString() != string.Empty)
{
SaveDetails(ViewState["QuestionID"].ToString());
foreach (Control contrl in this.Controls)
{
contrl.Visible = false;
}
}
else
{
SaveDetails();
foreach (Control contrl in this.Controls)
{
contrl.Visible = false;
}
}
Label lblMessage = new Label();
lblMessage.Visible = true;
lblMessage.Text = "The Question is successfully saved and sent to reviewer for reviewing. Thanks for uploading.";
}
As you can see the redirection works for btnCancel successfully. I have not assigned it for btnSubmit cos it will then only redirect and will not go to the above specified code.Tried microsoft help they were also clueless.Answers will be appreciated.the project requirement has been modified. long time no answers please check more. Thanks in advance.
Add this code in your button click
string redirectURL = "http://ksreejit:32512/sites/SplTeam/Pages/QuizMasterDashboard.aspx";
this.Controls.Add(new LiteralControl("<script>window.location.href='" + redirectURL + "';</script>"));
For your btnSubmit button, don't add the attribute like you did for your btnCancel.
And then simply add a Response.Redirect(...); in your event method.
... lblMessage.Text = "The Question is successfully saved and sent to reviewer for reviewing. Thanks for uploading.";
Response.Redirect("http://ksreejit:32512/sites/SplTeam/Pages/QuizMasterDashboard.aspx");

custom facebook like button in flash(actionscript)

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

Facebook action script 3 API login/logout issue

I'm making mobile AIR app for Android using Flash builder 4.5, AIR 2.6, Facebook action script 3 API the latest version.
I have a problem with login/logout. I can login only one time - then my data caches somehow and Facebook automatically logs me in. When I call logout I receive response TRUE, but I don't really logout from system. Standard login dialog doesn't appear for me. I have already read a lot of articles on stackoverflow and open issues on official site, but none of them were helpfull. How can I solve this? Here is the code I use:
package
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.external.ExternalInterface;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.Capabilities;
import flash.system.Security;
import flash.display.Loader;
import com.facebook.graph.FacebookMobile;
public class TestProj extends Sprite
{
public function TestProj()
{
super();
//register to add to stage
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
}
private function onAddedToStage(event:Event):void
{
this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
FacebookMobile.init("195053007196177", initCallback);
}
private function initCallback(success:Object, fail:Object):void
{
var appPermissions:Array = new Array("read_stream", "offline_access", "publish_stream", "read_friendlists");
FacebookMobile.login(loginCallback, this.stage, appPermissions);
//FacebookMobile.logout(logoutCallback);
}
private function loginCallback(success:Object, fail:Object):void
{
//And here I always receive success with my UserID
//and login dialog don't appears to me before this
if (success)
{
trace("login ok");
}
else
trace("login failed");
}
private function logoutCallback(success:Object):void
{
//here I reseive "TRUE" always!!
trace(success);
}
}
}
You're only passing the 1st argument of logoutCallback to your logout method. If you add in the 2nd argument of your site url specified for your app, it should clear it out the html cookie for that window. Also, set FacebookMobile.manageSession = false;
FacebookMobile.logout(logoutCallback, "http://your_app_origin_url");
There is a potential, related bug that involves Desktop and Mobile not accessing or clearing the access token's the same way. For that, there's a hack that describes exposing the access token in FacebookMobile, then manually calling the "logout" method with the access token. The issue is described here, including a method called "reallyLogout". If what I've written above doesn't work, implement "reallyLogout".
When you log out, your app clears the local session but does not log you out of the system. This is clearly defined in the documentation for logout. Think about it, if you're logged into Facebook on your Smartphone, Web Browser, and now this Mobile Desktop App, and suddenly you log out... it shouldn't log you out EVERYWHERE, just within that browsers session. So pass that 2nd parameter.
I've had this exact problem, and after trying numerous fixes, this finally seems to work:
The default logout functionality seems to not be properly clearing cookies via the FacebookMobile actionscript API. The solution in comment #33 here worked for me, reproduced here. Make sure to sub in your own APP_ID:
function logout(e:MouseEvent):void {
FacebookMobile.logout(onLogout, "https://m.facebook.com/dialog/permissions.request?app_id=APP_ID&display=touch&next=http%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html&type=user_agent&perms=publish_stream&fbconnect=1");
}
function onLogout(result:Object):void
{
trace("Perfect Log Out!")
}
Have had this Android Facebook clean logout problem the whole day, manage to solve it. Hope it helps. Here is my FB mobile handlelogin code to ensure all fb cookies and sessions are being removed and user will need to relogin.
Sometimes FB server is very slow. Its best to put a timer before you call handleLoginClick() again
function handleLoginClick():void
{
trace("connecting to facebook");
if (FacebookMobile.getSession() == null)
{
FacebookMobile.init(APP_ID, onHandleInit, null);
FacebookMobile.manageSession = false
}
else
{
var webView:StageWebView = new StageWebView();
webView.viewPort = new Rectangle(0, 0, 1, 1);
webView.stage = this.stage;
webView.loadURL("https://m.facebook.com/logout.php?confirm=1&next=http://www.facebook.com&access_token=" + FacebookMobile.getSession().accessToken);
webView.addEventListener(Event.COMPLETE,webviewhandleLoad);
function webviewhandleLoad(e:Event)
{
FacebookMobile.logout(null, "http://apps.facebook.com/<appName>/");
FacebookMobile.logout(null, "http://www.facebook.com");
webView.dispose()
webView = null
setTimeout(handleLoginClick,3000)
}
}
}
look at the solution of this problem. Maby someone it helps:
var stage_ref:Stage = PlatformUtil.originalStage(); //my custom class to get stage
var webView:StageWebView = new StageWebView();
webView.viewPort = new Rectangle(0, 0, stage_ref.width, stage_ref.height);
FacebookMobile.login(loginCallback, stage_ref, appPermissions, webView);
http://code.google.com/p/facebook-actionscript-api/issues/detail?id=381
http://code.google.com/p/facebook-actionscript-api/issues/detail?id=382
http://code.google.com/p/facebook-actionscript-api/issues/detail?id=383