仕事で調査したので、メモ。今回は、人のプラグインを使って対応。
こちらの方の物を参考にして使わせてもらった。
Githubからダウンロード
SocialWorker.unitypackageをインポート
ヒエラルキーに、Assets/SocialWorker/Prefabs/SorcialWorkerを配置。
SorcialWorker.csがついてるから、たぶん初期化とかしているので、これ配置しないと、うまくいかない。スクリプトを書く
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TwitterSendTest : MonoBehaviour { [SerializeField]Text DebugOutputText; private string OutputText = ""; public void OnClickTwitterSendButton() { SWorker.SocialWorker.PostTwitter("Test", "", (SWorker.SocialWorkerResult swres) => { string res = "" + swres; AddDebugText(res); } ); } private void AddDebugText(string text) { OutputText += text + "\n"; DebugOutputText.text = OutputText; } }
これで、投稿確認できた。
ちなみに、アプリにTwitterがインストールされていないと、エラーメッセージとして、「NotAvailable」が返される。