/// <summary> /// 分享逻辑 /// </summary> private void Share() { string shareImgPath = Application.persistentDataPath + "/tempPics/shareImage.jpg"; ShareContent content = new ShareContent(); switch (shareType) { case ShareType.WeChat: content.SetImagePath(shareImgPath); // 设置分享的类型 content.SetShareType(ContentType.Image); // 直接分享 ssdk.ShareContent(PlatformType.WeChatMoments, content); break; case ShareType.Weibo: content.SetImagePath(shareImgPath); //设置分享的类型 content.SetShareType(ContentType.Image); //直接分享 ssdk.ShareContent(PlatformType.SinaWeibo, content); break; } }
/// <summary> /// 邀请微信好友 /// </summary> /// <param name="str"></param> public void InviteFriends(string nameId, string str = "") { if (!File.Exists(Application.persistentDataPath + iconPath)) { SQDebug.PrintToScreen("VistiteFriend222=" + Application.persistentDataPath + iconPath); byte[] b = icon.EncodeToPNG(); SQDebug.PrintToScreen("VistiteFriend2221=" + b.Length); try { File.WriteAllBytes(Application.persistentDataPath + iconPath, b); } catch (Exception ex) { SQDebug.PrintToScreen(ex); } SQDebug.PrintToScreen("VistiteFriend2223=" + Application.persistentDataPath + iconPath); } SQDebug.LogError(Application.persistentDataPath + iconPath); // ShareContent content = new ShareContent(); content.SetTitle("58麻将0429"); content.SetUrl("http://139.224.57.97/down/index.html"); content.SetText("房间号:" + nameId + "\n" + str); content.SetImagePath(Application.persistentDataPath + iconPath); content.SetShareType(ContentType.Webpage); SQDebug.PrintToScreen("VistiteFriend2224="); ssdk.ShareContent(PlatformType.WeChat, content); }
public static void ShareBattleBtnClick() { ShareContent content = new ShareContent(); content.SetImagePath(GetDefaultFilePath()); content.SetShareType(ContentType.Image); ssdk.ShareContent(PlatformType.WeChat, content); }
public void QQShare() { AddShareCallBack(); ShareContent content = new ShareContent(); content.SetImagePath(ScreenshotManager.Instance.savedPath); content.SetShareType(ContentType.Image); ssdk.ShareContent(PlatformType.QQ, content); }
/** * 执行分享到朋友圈的操作 */ private void shareAchievement(PlatformType platformType) { ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText(""); customizeShareParams.SetImagePath(picPath); customizeShareParams.SetShareType(ContentType.Image); customizeShareParams.SetObjectID(""); customizeShareParams.SetShareContentCustomize(platformType, customizeShareParams); shareSdk.ShareContent(platformType, customizeShareParams); }
public void DoShareTest() { ShareContent content = new ShareContent(); content.SetText("胶己人雀友会"); content.SetImageUrl("http://www.27toy.com/images/108.png"); content.SetTitle("潮汕麻将四人玩法\n邀请胶己人一起来麻将,三缺一就等你了"); content.SetUrl("http://27toy.com/"); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(PlatformType.WeChatMoments, content); }
void TypeIsWeChat(string Title, string Text, string ImageURL, string URL, int contentType, PlatformType ID) { ShareContent content = new ShareContent(); content.SetTitle(Title); content.SetText(Text); content.SetImageUrl(ImageURL); content.SetUrl(URL); content.SetShareType(contentType); ssdk.ShareContent(ID, content); Debug.Log("AAAAA Test ShareSDK C# 通过分享菜单分享Wechat" + Title + Text + ImageURL + URL + ID); }
public void fenxiang__QQ() //QQ分享 { ShareContent content = new ShareContent(); content.SetTitle("冬奥会知识比拼"); content.SetText("我获得了所有碎片,你能吗"); content.SetTitleUrl( "https://pan.download.com"); content.SetImageUrl( "https://image.baidu.com/search/index?tn=baiduimage&ct=201326592&lm=-1&cl=2&ie=gb18030&word=%B6%AC%D4%CB%BB%E1%BC%AA%CF%E9%CE%EF&fr=ala&ala=1&alatpl=adress&pos=0&hs=2&xthttps=000000"); content.SetShareType(ContentType.Image); shareSdk.ShareContent(PlatformType.QQ, content); }
/* * Text :分享的文字 * Title: 分享的标题 * TitleUrl :标题的网络链接(QQ和QQ空间使用 ) * SetImageUrl :iOS平台,本地以及网络图片都使用此方法 * image:android平台分享本地图片与网络图片都用此方法 * Url: 分享的链接(微信,微博,易信,Facebook等平台) * ShareType:分享类型(微信,易信) * FilePath:分享文件路径 (微信,易信) * MusicUrl :分享的音乐链接(微信,QQ,易信) */ public void fenxiang__QQ() //QQ分享 { ShareContent content = new ShareContent(); content.SetTitle("测试"); content.SetText("测试文本"); content.SetTitleUrl( "https://www.gamersky.com/showimage/id_gamersky.shtml?http://img1.gamersky.com/image2019/07/20190725_ls_red_141_2/gamersky_042origin_083_2019725182972C.jpg"); content.SetImageUrl( "https://www.gamersky.com/showimage/id_gamersky.shtml?http://img1.gamersky.com/image2019/07/20190725_ls_red_141_2/gamersky_042origin_083_2019725182972C.jpg"); content.SetShareType(ContentType.Image); shareSdk.ShareContent(PlatformType.QQ, content); // shareSdk.ShowPlatformList(null, content, 100, 100); }
void doShare(PlatformType type) { // 显示分享菜单 ShareContent content = new ShareContent(); content.SetText(Message.getText("gameTitle")); content.SetImageUrl("https://xuerong.github.io/mazeAndPacman/resource/icon.png"); content.SetTitle(Message.getText("gameTitle")); content.SetTitleUrl("https://xuerong.github.io/mazeAndPacman/"); // content.SetSite("迷宫与吃豆人"); // content.SetSiteUrl("https://xuerong.github.io/mazeAndPacman/"); content.SetUrl("https://xuerong.github.io/mazeAndPacman/"); // content.SetComment("迷宫与吃豆人"); // content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); // content.SetFilePath("https://xuerong.github.io/mazeAndPacman/resource/mi.apk"); content.SetShareType(ContentType.Webpage); //通过分享菜单分享 // ssdk.ShowPlatformList (null, content, 100, 100); //直接通过编辑界面分享 // ssdk.ShowShareContentEditor (PlatformType.WeChat, content); // // //直接分享 ssdk.ShareContent(type, content); shareWeChat1.transform.parent.gameObject.SetActive(false); }
public void ShareInTable() { #if UNITY_IPHONE ssdk = gameObject.GetComponent <ShareSDK>(); ssdk.shareHandler = ShareResultHandler; ShareContent content = new ShareContent(); content.SetText("Play Pusoy online with me! Click to join my table!"); content.SetUrl("https://www.unlipoker.com"); content.SetTitle("Unlipoker"); content.SetShareType(ContentType.Auto); ssdk.ShareContent(PlatformType.FacebookMessenger, content); #endif #if UNITY_ANDROID // Get the required Intent and UnityPlayer classes. AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); // Construct the intent. AndroidJavaObject intent = new AndroidJavaObject("android.content.Intent"); intent.Call <AndroidJavaObject>("setAction", intentClass.GetStatic <string>("ACTION_SEND")); intent.Call <AndroidJavaObject>("putExtra", intentClass.GetStatic <string>("EXTRA_TEXT"), "Play Pusoy online with me! Click to join my table! http://www.unlipoker.com"); intent.Call <AndroidJavaObject>("setPackage", "com.facebook.orca"); intent.Call <AndroidJavaObject>("setType", "*/*"); // Display the chooser. AndroidJavaObject currentActivity = unityPlayerClass.GetStatic <AndroidJavaObject>("currentActivity"); AndroidJavaObject chooser = intentClass.CallStatic <AndroidJavaObject>("createChooser", intent, "Share"); currentActivity.Call("startActivity", chooser); #endif }
//微信分享房间 public void Share(string roomId = null) { string room = (roomId == null) ? "" : "房间号是:" + roomId; string text = "大庆麻将.快来!" + room; ShareContent content = new ShareContent(); content.SetTitle("大庆麻将"); content.SetText(text); content.SetImageUrl("http://daqingmj.youhao88.com:8081/icon.png"); content.SetUrl("daqingmj.youhao88.com:8081/DaQingMJ.html"); content.SetShareType(ContentType.Webpage); shareSdk.ShareContent(PlatformType.WeChat, content); }
private void SdkShareContentRoom(PlatformType platform, string strdesc) { ShareContent content = new ShareContent(); string gamename = ""; content.SetText("金游房卡麻将"); content.SetImageUrl("http://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eqia1ia8X0cdqEibvoWwKrRBTonZcRSxQgNXJlRg6EULfPzia4kFd1uicBItwibQ1kqpnmoIyDaUtCE2uFg/132"); content.SetTitle("金游好友局 \n盐城3D麻将<房号:" + "888888" + "> (" + 1 + "局)"); content.SetTitleUrl("http://d.51v.cn/"); content.SetSite("麻友召集令"); content.SetSiteUrl("http://d.51v.cn/"); content.SetUrl("http://d.51v.cn/"); content.SetComment("http://d.51v.cn/"); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(platform, content); }
//void doLogin() //{ // if (Game.SocketHall.SocketNetTools.Connected) // { // Game.SocketHall.LoginMsg(_opendid, _token, 3); // print("doLogin1" + _opendid + " " + _token); // } // else // { // Game.SocketHall.SocketNetTools.OnConnect -= OnConnect; // Game.SocketHall.SocketNetTools.OnConnect += OnConnect; // Game.InitHallSocket(GlobalConfig.address); // print("doLogin2" + _opendid + " " + _token); // } //} //微信分享房间 public void Share(string roomId = null) { string room = (roomId == null) ? "" : "房间号是:" + roomId; string text = "齐齐哈尔麻将.快来!" + room; ShareContent content = new ShareContent(); content.SetTitle("齐齐哈尔麻将"); content.SetText(text); content.SetImageUrl("http://www.youhao88.com:8081/icon.png"); content.SetUrl("www.qiqihaermj.youhao88.com:8081/index2.html"); content.SetShareType(ContentType.Webpage); shareSdk.ShareContent(PlatformType.WeChat, content); }
private IEnumerator Share(ShareContent content) { yield return(new WaitForSeconds(.3f)); if (File.Exists(Utils.GetShareGameResultUrl())) { ssdk.ShareContent(PlatformType.WeChat, content); } }
/// <summary> /// 邀请微信好友 /// </summary> /// <param name="roomId">23456</param> /// <param name="des">描述信息</param> /// <param name="plat">平台</param> public void InviteFriends(string roomId, string des, PlatformType plat) { SQDebug.Log(Application.persistentDataPath + iconPath); // ShareDescConfig con = ConfigManager.GetConfigs <ShareDescConfig>()[0] as ShareDescConfig; ShareContent content = new ShareContent(); content.SetTitle(con.Title); string str = string.Format(con.downUrl, PlayerModel.Inst.UserInfo.clubId); SQDebug.Log("分享连接:" + str); content.SetUrl(str); content.SetText("房间:" + roomId + "," + des + ",邀您来战!"); content.SetImageUrl(con.iconUrl); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(plat, content); }
public void ShareWeChat(string _title, string _text, string _url, bool _isMoments) { ShareContent content = new ShareContent(); content.SetText(_text); content.SetImageUrl(ABTool.ResUrl + "/thumblogo.jpg"); content.SetTitle(_title); content.SetTitleUrl(_url); content.SetUrl(_url); content.SetShareType(ContentType.Webpage); if (_isMoments) { sdk.ShareContent(PlatformType.WeChatMoments, content); } else { sdk.ShareContent(PlatformType.WeChat, content); } }
private void Share() { string shareImgPath = Application.persistentDataPath + "/tempPics/shareImage.png"; ShareContent content = new ShareContent(); switch (currentShareType) { case ShareType.WeChat: content.SetText("分享的内容"); content.SetTitle("分享的标题"); content.SetAddress("分享的位置"); content.SetDesc("分享的描述"); content.SetComment("分享的评论"); content.SetImagePath(shareImgPath); //设置分享的类型 content.SetShareType(ContentType.Auto); //直接分享 ssdk.ShareContent(PlatformType.WeChatMoments, content); break; case ShareType.Weibo: string currentThoughts = "1234566789"; content.SetText(currentThoughts); content.SetImagePath(shareImgPath); //设置分享的类型 content.SetShareType(ContentType.Image); //直接分享 ssdk.ShareContent(PlatformType.SinaWeibo, content); break; } }
public static void Share(int type, ShareContent content, LuaFunction func = null) { Debug.Log("Start Share "); ConfigSSDK(); PlatformType finaltype = ThirdPlatformTool.fromInt(type); _SSDK.ShareContent(finaltype, content); //_SSDK.ShareContent (PlatformType.WeChat, content); _ShareLuaFunc = func; }
public void TestShare() { ShareContent content = new ShareContent(); content.SetText("TestShare"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetShareType(ContentType.Text); ssdk.ShareContent(PlatformType.QQ, content); }
/// <summary> /// Share a local image /// <para> /// Callback result: 0 = Begin 1 = Success 2 = Failed 3 = Cancled 4 = Begin Upload /// </para> /// </summary> public static int ShareImage(PlatformType type, string path, string text, Action <int, int> callback = null, int contentType = -1) { #if !UNITY_EDITOR if (m_shareContent == null) { m_shareContent = new ShareContent(); } var title = Util.GetString(9005, 5); var titleUrl = Util.GetString(9005, 6); m_shareContent.SetImagePath(path); if (type == PlatformType.SinaWeibo) { m_shareContent.SetText(title + titleUrl); } else if (type == PlatformType.QZone || type == PlatformType.QQ) { m_shareContent.SetTitle(title); m_shareContent.SetTitleUrl(titleUrl); m_shareContent.SetText(text); if (type == PlatformType.QZone) { #if UNITY_ANDROID m_shareContent.SetSite(""); m_shareContent.SetSiteUrl(titleUrl); #endif } } else if (type == PlatformType.WeChat || type == PlatformType.WeChatMoments) { if (contentType == -1) { contentType = ContentType.Image; } m_shareContent.SetShareType(contentType); m_shareContent.SetTitle(title); if (contentType == ContentType.Webpage) { m_shareContent.SetUrl(titleUrl); } m_shareContent.SetText(text); } m_onShare = callback; return(m_shareSDK.ShareContent(type, m_shareContent)); #endif return(0); }
public void ShareClick() { Debug.Log("Share Click"); var game = gamePlayerController.game; ShareContent content = new ShareContent(); content.SetTitle("房间【" + game.roomNo + "】"); content.SetText("【玩法:AA支付," + game.totalRoundCount + "局,【4,6,8分】,明牌抢庄,闲家推注】"); content.SetImageUrl("http://niu.yhkamani.com:3001/images/icon.png"); content.SetUrl("http://niu.yhkamani.com/share?room=" + game.roomNo); //content.SetUrlDescription("【玩法:AA支付," + game.totalRoundCount + "局,【4,6,8分】,明牌抢庄,闲家推注】"); //content.SetDesc ("【玩法:AA支付," + game.totalRoundCount + "局,【4,6,8分】,明牌抢庄,闲家推注】"); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(PlatformType.WeChat, content); }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } //float btnWidth = 165 * scale; float btnWidth = Screen.width / 5 * 2; float btnHeight = Screen.height / 25; float btnTop = 30 * scale; float btnGap = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(13 * scale); if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(PlatformType.QQ); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(PlatformType.QQ); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Show Share Menu")) { ShareContent content = new ShareContent(); //(Android only) 隐藏九宫格里面不需要用到的平台(仅仅是不显示平台) //(Android only) 也可以把jar包删除或者把Enabl属性e改成false(对应平台的全部功能将用不了) String[] platfsList = { ((int)PlatformType.QQ).ToString(), ((int)PlatformType.Facebook).ToString(), ((int)PlatformType.TencentWeibo).ToString() }; content.SetHidePlatforms(platfsList); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //(Android only) 针对Android绕过审核的多图分享,传图片String数组 String[] imageArray = { "/sdcard/test.jpg", "http://f1.webshare.mob.com/dimgs/1c950a7b02087bf41bc56f07f7d3572c11dfcf36.jpg", "/sdcard/test.jpg" }; content.SetImageArray(imageArray); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); //不同平台分享不同内容 ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText("Sina share content"); customizeShareParams.SetImageUrl("http://git.oschina.net/alexyu.yxj/MyTmpFiles/raw/master/kmk_pic_fld/small/107.JPG"); customizeShareParams.SetShareType(ContentType.Text); customizeShareParams.SetObjectID("SinaID"); content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams); //优先客户端分享 // content.SetEnableClientShare(true); //使用微博API接口应用内分享 iOS only // content.SetEnableSinaWeiboAPIShare(true); //通过分享菜单分享 ssdk.ShowPlatformList(null, content, 100, 100); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Show Share View")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share Content")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); // content.SetTitleUrl("http://www.mob.com"); // content.SetSite("Mob-ShareSDK"); // content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://qjsj.youzu.com/jycs/"); // content.SetComment("test description"); // content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(PlatformType.WeChat, content); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); ssdk.GetFriendList(PlatformType.SinaWeibo, 15, 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.DisableSSO(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(PlatformType.SinaWeibo, "3189087725"); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShareWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件分享【本接口功能仅暂时支持iOS】 ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnWidth += 80 * scale; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareMenuWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件展示分享菜单分享【本接口功能仅暂时支持iOS】 ssdk.ShowPlatformListWithContentName("ShareSDK", customFields, null, 100, 100); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareViewWithContentName")) { Hashtable customFields = new Hashtable(); //根据配置文件展示编辑界面分享【本接口功能仅暂时支持iOS】 customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; ssdk.ShowShareContentEditorWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "SMS Authorize")) { ssdk.Authorize(PlatformType.SMS); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share wxMiniProgram (ios only)")) { ShareContent content = new ShareContent(); content.SetTitle("MiniProgram"); content.SetText("test MiniProgram"); content.SetUrl("http://www.mob.com"); content.SetMiniProgramPath("pages/index/index"); content.SetThumbImageUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527484508213&di=d993c2ca41fec50717d137718511120f&imgtype=0&src=http%3A%2F%2Fimg5.2345.com%2Fduoteimg%2FzixunImg%2Flocal%2F2017%2F05%2F03%2F14938009295612.jpg"); content.SetMiniProgramHdThumbImage("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522154322305&di=7f4bf3d0803fe8c2c66c140f0a6ea0b4&imgtype=0&src=http%3A%2F%2Fa4.topitme.com%2Fo%2F201007%2F29%2F12803876734174.jpg"); content.SetMiniProgramUserName("gh_afb25ac019c9"); content.SetMiniProgramWithShareTicket(true); content.SetMiniProgramType(0); content.SetShareType(ContentType.MiniProgram); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.WeChat, content); ssdk.ShareContent(PlatformType.WeChat, shareContent); } }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } //float btnWidth = 165 * scale; float btnWidth = Screen.width / 5 * 2; float btnHeight = Screen.height / 25; float btnTop = 30 * scale; float btnGap = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(13 * scale); if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(PlatformType.Douyin); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(PlatformType.Douyin); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Show Share Menu")) { ShareContent content = new ShareContent(); // //(Android only) 隐藏九宫格里面不需要用到的平台(仅仅是不显示平台) // //(Android only) 也可以把jar包删除或者把Enabl属性e改成false(对应平台的全部功能将用不了) String[] platfsList = { ((int)PlatformType.QQ).ToString(), ((int)PlatformType.Facebook).ToString(), ((int)PlatformType.TencentWeibo).ToString() }; content.SetHidePlatforms(platfsList); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //(Android only) 针对Android绕过审核的多图分享,传图片String数组 String[] imageArray = { "/sdcard/test.jpg", "http://f1.webshare.mob.com/dimgs/1c950a7b02087bf41bc56f07f7d3572c11dfcf36.jpg", "/sdcard/test.jpg" }; content.SetImageArray(imageArray); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl( "http://i.y.qq.com/v8/playsong.html?hostuin=0&songid=&songmid=002x5Jje3eUkXT&_wv=1&source=qq&appshare=iphone&media_mid=002x5Jje3eUkXT"); content.SetShareType(ContentType.Image); //不同平台分享不同内容 ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText("Sina share content"); customizeShareParams.SetImageUrl( "http://git.oschina.net/alexyu.yxj/MyTmpFiles/raw/master/kmk_pic_fld/small/107.JPG"); customizeShareParams.SetShareType(ContentType.Text); customizeShareParams.SetObjectID("SinaID"); content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams); //优先客户端分享 content.SetEnableClientShare(true); //使用微博API接口应用内分享 iOS only content.SetEnableSinaWeiboAPIShare(true); //通过分享菜单分享 ssdk.ShowPlatformList(null, content, 100, 100); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Show Share View")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share Content")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //content.SetTitleUrl("http://www.mob.com"); //content.SetSite("Mob-ShareSDK"); //content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://qjsj.youzu.com/jycs/"); //content.SetComment("test description"); //content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShareContent(PlatformType.QQ, content); // // 开发者要自己传入Activity 在9.0及其以上的系统 // // AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); // // AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); // // content.SetActivity(jo); // // Debug.Log("QQQ 测试传入的activity ==================>>> " + jo); // ShareContent content = new ShareContent(); // content.SetFilePath("/storage/emulated/0/douyin.mp4"); // content.SetShareType(ContentType.Video); // ssdk.ShareContent (PlatformType.Douyin, content); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); // ssdk.GetFriendList (PlatformType.SinaWeibo, 15, 0); ssdk.openMiniProgram("gh_afb25ac019c9", "pages/index/index", 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.DisableSSO(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(PlatformType.SinaWeibo, "3189087725"); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShareWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件分享【本接口功能仅暂时支持iOS】 ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnWidth += 80 * scale; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareMenuWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件展示分享菜单分享【本接口功能仅暂时支持iOS】 ssdk.ShowPlatformListWithContentName("ShareSDK", customFields, null, 100, 100); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareViewWithContentName")) { Hashtable customFields = new Hashtable(); //根据配置文件展示编辑界面分享【本接口功能仅暂时支持iOS】 customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; ssdk.ShowShareContentEditorWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "SMS Authorize")) { ssdk.Authorize(PlatformType.SMS); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share wxMiniProgram (ios only)")) { ShareContent content = new ShareContent(); content.SetTitle("MiniProgram"); content.SetText("test MiniProgram"); content.SetUrl("http://www.mob.com"); content.SetMiniProgramPath("pages/index/index"); content.SetThumbImageUrl( "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527484508213&di=d993c2ca41fec50717d137718511120f&imgtype=0&src=http%3A%2F%2Fimg5.2345.com%2Fduoteimg%2FzixunImg%2Flocal%2F2017%2F05%2F03%2F14938009295612.jpg"); content.SetMiniProgramHdThumbImage( "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522154322305&di=7f4bf3d0803fe8c2c66c140f0a6ea0b4&imgtype=0&src=http%3A%2F%2Fa4.topitme.com%2Fo%2F201007%2F29%2F12803876734174.jpg"); content.SetMiniProgramUserName("gh_afb25ac019c9"); content.SetMiniProgramWithShareTicket(true); content.SetMiniProgramType(0); content.SetShareType(ContentType.MiniProgram); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.WeChat, content); ssdk.ShareContent(PlatformType.WeChat, shareContent); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share Sina LinkCard")) { #if UNITY_IPHONE ShareContent content = new ShareContent(); content.SetText("sina LinkCard"); content.SetUrl("http://www.mob.com"); content.SetImageUrl("http://www.mob.com/assets/images/ShareSDK_pic_1-09d293a6.png");//必须为网络图片 content.SetSinaLinkCard(true); content.SetSinaCardTitle("这是Title"); content.SetSinaCardSummary("这是Summary"); content.SetShareType(ContentType.Webpage); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.SinaWeibo, content); ssdk.ShareContent(PlatformType.SinaWeibo, shareContent); #elif UNITY_ANDROID JsonData jsonData = new JsonData(); jsonData["url"] = "http://wx4.sinaimg.cn/large/006WfoFPly1fq0jo9svnaj30dw0dwdhv.jpg"; jsonData["width"] = "120"; jsonData["height"] = "120"; ShareContent content = new ShareContent(); content.SetText("sina LinkCard"); content.SetSinaCardCreateAtAndroid("2019-01-24"); content.SetSinaCardDisplayNameAndroid("displayName"); content.SetSinaCardSummary("Summary"); content.SetSinaCardURLAndroid("http://www.mob.com/"); content.SetSinaCardTypeAndroid("webpage"); content.SetSinaCardImageAndroid(jsonData); content.SetEnableClientShare(true); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.SinaWeibo, content); ssdk.ShareContent(PlatformType.SinaWeibo, shareContent); #endif } }
public void ShareWeChatFriend(ShareContent content) { #if UNITY_ANDROID || UNITY_IPHONE ssdk.ShareContent(PlatformType.WeChat, content); #endif }
public void ShareFacebook(ShareContent content) { ssdk.ShareContent(PlatformType.Facebook, content); }
/// <summary> /// Shares the wei chat. 微信分享 /// </summary> /// <param name="value">Value.</param> public void ShareWeiChat(ShareContent value) { ssdk.ShareContent(PlatformType.WeChat, value); }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } //float btnWidth = 165 * scale; float btnWidth = Screen.width / 5 * 2; float btnWidth2 = btnWidth + 80 * scale; float btnHeight = Screen.height / 25; float btnTop = 30 * scale; float btnGap = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(13 * scale); if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); #if UNITY_ANDROID ssdk.Authorize(PlatformType.SinaWeibo); #elif UNITY_IPHONE ssdk.Authorize(PlatformType.Facebook); #endif } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info")) { //ssdk.GetUserInfo(PlatformType.Douyin); print("share result :" + ssdk.GetUserInfo(PlatformType.QQ)); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Show Share Menu")) { ShareContent content = new ShareContent(); // //(Android only) 隐藏九宫格里面不需要用到的平台(仅仅是不显示平台) // //(Android only) 也可以把jar包删除或者把Enabl属性e改成false(对应平台的全部功能将用不了) String[] platfsList = { ((int)PlatformType.Facebook).ToString(), ((int)PlatformType.TencentWeibo).ToString() }; content.SetHidePlatforms(platfsList); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //(Android only) 针对Android绕过审核的多图分享,传图片String数组 String[] imageArray = { "/sdcard/test.jpg", "http://f1.webshare.mob.com/dimgs/1c950a7b02087bf41bc56f07f7d3572c11dfcf36.jpg", "/sdcard/test.jpg" }; content.SetImageArray(imageArray); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://i.y.qq.com/v8/playsong.html?hostuin=0&songid=&songmid=002x5Jje3eUkXT&_wv=1&source=qq&appshare=iphone&media_mid=002x5Jje3eUkXT"); content.SetShareType(ContentType.Image); //不同平台分享不同内容 ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText("Sina share content"); customizeShareParams.SetImageUrl("http://git.oschina.net/alexyu.yxj/MyTmpFiles/raw/master/kmk_pic_fld/small/107.JPG"); customizeShareParams.SetShareType(ContentType.Text); customizeShareParams.SetObjectID("SinaID"); content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams); //优先客户端分享 content.SetEnableClientShare(true); //使用微博API接口应用内分享 iOS only content.SetEnableSinaWeiboAPIShare(true); //通过分享菜单分享 ssdk.ShowPlatformList(null, content, 100, 100); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Show Share View")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "Share Content")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); //content.SetTitleUrl("http://www.mob.com"); //content.SetSite("Mob-ShareSDK"); //content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://qjsj.youzu.com/jycs/"); //content.SetComment("test description"); //content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShareContent(PlatformType.Oasis, content); // // 开发者要自己传入Activity 在9.0及其以上的系统 // // AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); // // AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); // // content.SetActivity(jo); // // Debug.Log("QQQ 测试传入的activity ==================>>> " + jo); // ShareContent content = new ShareContent(); // content.SetFilePath("/storage/emulated/0/douyin.mp4"); // content.SetShareType(ContentType.Video); // ssdk.ShareContent (PlatformType.Douyin, content); } //if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) //{ //获取新浪微博好友,第一页,每页15条数据 //print ("Click Btn Of Get Friends SinaWeibo"); // ssdk.GetFriendList (PlatformType.SinaWeibo, 15, 0); //ssdk.openMiniProgram("gh_afb25ac019c9","pages/index/index",0); //} btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "Get Token ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.QQ); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } //if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap , btnTop, btnWidth, btnHeight), "Close SSO Auth")) //{ //ssdk.DisableSSO (true); //} btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.QQ); } //if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Add Friend ")) //{ //关注新浪微博 //ssdk.AddFriend (PlatformType.SinaWeibo, "3189087725"); //} btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "ShareWithContentName(IOS only)")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件分享【本接口功能仅暂时支持iOS】 ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "ShowShareMenuWithContentName(IOS only)")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件展示分享菜单分享【本接口功能仅暂时支持iOS】 ssdk.ShowPlatformListWithContentName("ShareSDK", customFields, null, 100, 100); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "ShowShareViewWithContentName(IOS only)")) { Hashtable customFields = new Hashtable(); //根据配置文件展示编辑界面分享【本接口功能仅暂时支持iOS】 customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; ssdk.ShowShareContentEditorWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "SMS Authorize")) { ssdk.Authorize(PlatformType.SMS); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "submitPolicyGrantResult")) { Debug.Log("ssdk ======> " + ssdk); Debug.Log("mobsdk ======> " + mobsdk); mobsdk.submitPolicyGrantResult(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "getPrivacyPolicy")) { Debug.Log("ssdk ======> " + ssdk); Debug.Log("mobsdk ======> " + mobsdk); #if UNITY_IPHONE mobsdk.getPrivacyPolicy(true); #elif UNITY_ANDROID mobsdk.getPrivacyPolicy(true); Debug.Log("mobsdk getPrivacyPolicy======> " + mobsdk.getPrivacyPolicy(true)); #endif } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share wxMiniProgram")) { #if UNITY_IPHONE ShareContent content = new ShareContent(); content.SetTitle("MiniProgram"); content.SetText("test MiniProgram"); content.SetUrl("http://www.mob.com"); content.SetMiniProgramPath("pages/index/index"); content.SetThumbImageUrl("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527484508213&di=d993c2ca41fec50717d137718511120f&imgtype=0&src=http%3A%2F%2Fimg5.2345.com%2Fduoteimg%2FzixunImg%2Flocal%2F2017%2F05%2F03%2F14938009295612.jpg"); content.SetMiniProgramHdThumbImage("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522154322305&di=7f4bf3d0803fe8c2c66c140f0a6ea0b4&imgtype=0&src=http%3A%2F%2Fa4.topitme.com%2Fo%2F201007%2F29%2F12803876734174.jpg"); content.SetMiniProgramUserName("gh_afb25ac019c9"); content.SetMiniProgramWithShareTicket(true); // iOS/Android 微信小程序的版本(0-正式,1-开发,2-体验) content.SetMiniProgramType(0); //content.SetShareType (ContentType.MiniProgram); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.WeChat, content); ssdk.ShareContent(PlatformType.WeChat, shareContent); #elif UNITY_ANDROID ShareContent content = new ShareContent(); content.SetTitle("MiniProgram"); content.SetText("test MiniProgram"); content.SetUrl("http://www.mob.com"); content.SetMiniProgramType(0); content.SetMiniProgramUserName("gh_52568203455c"); content.SetImageUrl("http://pic28.photophoto.cn/20130818/0020033143720852_b.jpg"); content.SetShareType(ContentType.MiniProgram); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.WeChat, content); ssdk.ShareContent(PlatformType.WeChat, shareContent); #endif } // if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Share qqMiniProgram(IOS only)")) { #if UNITY_IPHONE ShareContent content = new ShareContent(); content.SetTitle("MiniProgram"); content.SetText("test MiniProgram"); content.SetUrl("http://www.mob.com"); content.SetThumbImageUrl("http://download.sdk.mob.com/web/images/2019/07/30/14/1564468183056/750_750_65.12.png"); content.SetMiniProgramPath("pages/index/index"); content.SetMiniProgramHdThumbImage("http://download.sdk.mob.com/web/images/2019/07/30/14/1564468183056/750_750_65.12.png"); content.SetMiniProgramAppID("1108318575"); content.SetMiniProgramWebpageUrl("www.qq.com"); //iOS/Android QQ小程序的类型,默认正式版(3),可选测试版(1)、预览版(4) content.SetMiniProgramType(3); content.SetShareType(ContentType.MiniProgram); ShareContent shareContent = new ShareContent(); shareContent.SetShareContentCustomize(PlatformType.QQ, content); ssdk.ShareContent(PlatformType.QQ, shareContent); #elif UNITY_ANDROID //=============================================================== //when you test QQ miniprogram, you should use this params //At the same time, the package name and signature should //correspond to the package name signature of the specific //QQ sharing small program applied in the background of tencent //=============================================================== //ShareContent content = new ShareContent(); //content.SetTitle("MiniProgram"); //content.SetText("test MiniProgram"); //content.SetTitleUrl("http://www.mob.com"); //content.SetImageUrl("http://www.3wyu.com/wp-content/uploads/6e0eaf15gy1fvr5tnm2dfj20f108gtad.jpg");//必须为网络图片 //content.SetShareType(ContentType.QQ_MINI_PROGRAM); //content.SetMiniProgramAppID("1108318575"); //content.SetMiniProgramPath("page/share/index.html?share_name=QQ%E9%9F%B3%E4%B9%90&share_key=5aIqFGg&from=disk"); //content.SetQQMiniProgramType(""); //ShareContent shareContent = new ShareContent(); //shareContent.SetShareContentCustomize(PlatformType.QQ, content); //ssdk.ShareContent(PlatformType.QQ, shareContent); #endif } //btnTop += btnHeight + 20 * scale; //if (GUI.Button(new Rect((Screen.width - btnWidth2) / 2, btnTop, btnWidth2, btnHeight), "Share Sina LinkCard")) //{ //#if UNITY_IPHONE //ShareContent content = new ShareContent(); //content.SetText("sina LinkCard"); //content.SetUrl("http://www.mob.com"); //content.SetImageUrl("http://www.mob.com/assets/images/ShareSDK_pic_1-09d293a6.png");//必须为网络图片 //content.SetSinaLinkCard(true); //content.SetSinaCardTitle("这是Title"); //content.SetSinaCardSummary("这是Summary"); //content.SetShareType(ContentType.Webpage); //ShareContent shareContent = new ShareContent(); //shareContent.SetShareContentCustomize(PlatformType.SinaWeibo, content); //ssdk.ShareContent(PlatformType.SinaWeibo, shareContent); //#elif UNITY_ANDROID //JsonData jsonData = new JsonData(); //jsonData["url"] = "http://wx4.sinaimg.cn/large/006WfoFPly1fq0jo9svnaj30dw0dwdhv.jpg"; //jsonData["width"] = "120"; //jsonData["height"] = "120"; //ShareContent content = new ShareContent(); //content.SetText("sina LinkCard"); //content.SetSinaCardCreateAtAndroid("2019-01-24"); //content.SetSinaCardDisplayNameAndroid("displayName"); //content.SetSinaCardSummary("Summary"); //content.SetSinaCardURLAndroid("http://www.mob.com/"); //content.SetSinaCardTypeAndroid("webpage"); //content.SetSinaCardImageAndroid(jsonData); //content.SetEnableClientShare(true); //ShareContent shareContent = new ShareContent(); //shareContent.SetShareContentCustomize(PlatformType.SinaWeibo, content); //ssdk.ShareContent(PlatformType.SinaWeibo, shareContent); //#endif //} }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } float btnWidth = 165 * scale; float btnHeight = 30 * scale; float btnTop = 20 * scale; float btnGap = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(14 * scale); if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(PlatformType.QQ); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(PlatformType.SinaWeibo); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Show Share Menu")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); //不同平台分享不同内容 ShareContent customizeShareParams = new ShareContent(); customizeShareParams.SetText("Sina share content"); customizeShareParams.SetImageUrl("http://git.oschina.net/alexyu.yxj/MyTmpFiles/raw/master/kmk_pic_fld/small/107.JPG"); customizeShareParams.SetShareType(ContentType.Text); customizeShareParams.SetObjectID("SinaID"); content.SetShareContentCustomize(PlatformType.SinaWeibo, customizeShareParams); //优先客户端分享 // content.SetEnableClientShare(true); //使用微博高级接口进行本地图片 文字 应用内分享 17年6月30日后需申请高级接口 // content.SetEnableAdvancedInterfaceShare(true); //通过分享菜单分享 ssdk.ShowPlatformList(null, content, 100, 100); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Show Share View")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); content.SetTitleUrl("http://www.mob.com"); content.SetSite("Mob-ShareSDK"); content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://www.mob.com"); content.SetComment("test description"); content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Image); ssdk.ShowShareContentEditor(PlatformType.SinaWeibo, content); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Share Content")) { ShareContent content = new ShareContent(); content.SetText("this is a test string."); content.SetImageUrl("http://ww3.sinaimg.cn/mw690/be159dedgw1evgxdt9h3fj218g0xctod.jpg"); content.SetTitle("test title"); // content.SetTitleUrl("http://www.mob.com"); // content.SetSite("Mob-ShareSDK"); // content.SetSiteUrl("http://www.mob.com"); content.SetUrl("http://qjsj.youzu.com/jycs/"); // content.SetComment("test description"); // content.SetMusicUrl("http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"); content.SetShareType(ContentType.Webpage); ssdk.ShareContent(PlatformType.WeChat, content); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); ssdk.GetFriendList(PlatformType.SinaWeibo, 15, 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.DisableSSO(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnGap) / 2 - btnWidth, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } if (GUI.Button(new Rect((Screen.width - btnGap) / 2 + btnGap, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(PlatformType.SinaWeibo, "3189087725"); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShareWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件分享【本接口功能仅暂时支持iOS】 ssdk.ShareWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } btnWidth += 80 * scale; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareMenuWithContentName")) { Hashtable customFields = new Hashtable(); customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; //根据配置文件展示分享菜单分享【本接口功能仅暂时支持iOS】 ssdk.ShowPlatformListWithContentName("ShareSDK", customFields, null, 100, 100); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "ShowShareViewWithContentName")) { Hashtable customFields = new Hashtable(); //根据配置文件展示编辑界面分享【本接口功能仅暂时支持iOS】 customFields["imgUrl"] = "http://ww1.sinaimg.cn/mw690/006dJESWgw1f6iyb8bzraj31kw0v67a2.jpg"; ssdk.ShowShareContentEditorWithContentName(PlatformType.SinaWeibo, "ShareSDK", customFields); } }
void OnGUI() { GUI.skin = demoSkin; float scale = 1.0f; if (Application.platform == RuntimePlatform.IPhonePlayer) { scale = Screen.width / 320; } float btnWidth = 200 * scale; float btnHeight = 45 * scale; float btnTop = 20 * scale; GUI.skin.button.fontSize = Convert.ToInt32(16 * scale); reqID += 1; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Authorize")) { print(ssdk == null); ssdk.Authorize(reqID, PlatformType.SinaWeibo); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get User Info")) { ssdk.GetUserInfo(reqID, PlatformType.SinaWeibo); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share Menu")) { Hashtable content = new Hashtable(); content["content"] = "this is a test string."; content["image"] = "https://f1.webshare.mob.com/code/demo/img/1.jpg"; content["title"] = "test title"; content["description"] = "test description"; content["url"] = "http://sharesdk.cn"; //type只对微信分享有效,分享图片Image,分享链接类型为WebPage/News content["type"] = ContentType.Video; content["siteUrl"] = "http://sharesdk.cn"; content["shareTheme"] = "classic"; //ShareTheme has only two value which are skyblue and classic content["site"] = "ShareSDK"; content["musicUrl"] = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"; //用sharesdk提供的onekeyshare库,有界面的快捷分享,包括九宫格和skybule风格 #if UNITY_IPHONE //仅支持iOS,定制新浪的分享内容Example,各平台所支持的字段请参考文档 Hashtable sinaContent = new Hashtable(); sinaContent["content"] = "the sina custom content string"; sinaContent["title"] = "the sina title"; //string path = Application.dataPath+"/Raw"+"/ShareSDK.jpg"; string path = "http://img.baidu.com/img/image/zhenrenmeinv0207.jpg"; sinaContent["image"] = path; sinaContent["url"] = "http://sharesdk.cn"; //iOS分享图文类型为Image,分享链接类型为WebPage/News sinaContent["type"] = ContentType.Image; sinaContent["lat"] = "33.33"; sinaContent["lng"] = "99.99"; sinaContent["objID"] = @"sinaID"; content.Add((int)PlatformType.SinaWeibo, sinaContent); #endif ssdk.ShowShareMenu(reqID, null, content, 100, 100); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share View")) { Hashtable content = new Hashtable(); content["content"] = "this is a test string."; content["image"] = "https://f1.webshare.mob.com/code/demo/img/1.jpg"; content["title"] = "test title"; content["description"] = "test description"; content["url"] = "http://sharesdk.cn"; content["type"] = ContentType.News; content["siteUrl"] = "http://sharesdk.cn"; content["shareTheme"] = "classic"; //ShareTheme has only two value which are skyblue and classic content["site"] = "ShareSDK"; content["musicUrl"] = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"; //用sharesdk提供的onekeyshare库,有界面的快捷分享,包括九宫格和skybule风格 ssdk.ShowShareView(reqID, PlatformType.TencentWeibo, content); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share Content")) { Hashtable content = new Hashtable(); content["content"] = "this is a test string."; content["image"] = "https://f1.webshare.mob.com/code/demo/img/1.jpg"; content["title"] = "test title"; content["description"] = "test description"; content["url"] = "http://sharesdk.cn"; content["type"] = ContentType.Image; content["siteUrl"] = "http://sharesdk.cn"; content["site"] = "ShareSDK"; content["musicUrl"] = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3"; ssdk.ShareContent(reqID, PlatformType.SinaWeibo, content); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo ")) { //获取新浪微博好友,第一页,每页15条数据 print("Click Btn Of Get Friends SinaWeibo"); ssdk.GetFriendList(reqID, PlatformType.SinaWeibo, 15, 0); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo ")) { Hashtable authInfo = ssdk.GetAuthInfo(PlatformType.SinaWeibo); print("share result :"); print(MiniJSON.jsonEncode(authInfo)); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Close SSO Auth")) { ssdk.CloseSSOWhenAuthorize(true); } btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Remove Authorize ")) { ssdk.CancelAuthorize(PlatformType.SinaWeibo); } reqID += 1; btnTop += btnHeight + 20 * scale; if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Add Friend ")) { //关注新浪微博 ssdk.AddFriend(reqID, PlatformType.SinaWeibo, "3189087725"); } }