General Features

This document provides the API details for the most common Facebook SDK methods. The architecture follows, as much as possible within the constraints of the supported platforms and of Mono.



Before we can use OAuth Twitter API, we need to initialize SPTwitter manager.  If the user was authenticated with our application in the previous session we do not need to call auth again, user will be authenticated after init action completed.


SPTwitter.instance.OnTwitterInitedAction += OnTwitterInitedAction;

void OnTwitterInitedAction (TWResult result) {
	if(result.IsSucceeded) {
		//user authed


SPTwitter.instance.OnTwitterInitedAction += OnTwitterInitedAction;

void OnTwitterInitedAction (TWResult result) {
	if(result.IsSucceeded) {
		//user authed


Before we can use Twitter OAuth API, user should grant permission to the application. Following code snippet shows how to run user authentication flow.

SPTwitter.instance.OnAuthCompleteAction += OnAuthCompleteAction;

void OnAuthCompleteAction (TWResult result) {
	if(result.IsSucceeded) {
		//user authed


You can provide the way to log out for your user. The  following methods will destroy user authentication.



Getting User Data

After auth is completed, user data can be retrieved as showed on the code snippet below:

SPTwitter.instance.OnUserDataRequestCompleteAction += OnUserDataRequestCompleteAction;
void OnUserDataRequestCompleteAction (TWResult result) {
	if(result.IsSucceeded) {
		IsUserInfoLoaded = true;
	} else {
		Debug.Log("Opps, user data load failed, something was wrong");

Loaded user data can be accessed with:



The user data is represented as TwitterUserInfo class:

public void LoadProfileImage()
public void LoadBackgroundImage()

public string rawJSON {get;}
public string id {get;}
public string name {get;}
public string description {get;}
public string screen_name {get;}
public string location {get;}
public string lang {get;}
public string profile_image_url {get;}
public string profile_image_url_https {get;}
public string profile_background_image_url {get;}
public string profile_background_image_url_https {get;}
public int friends_count {get;}
public int statuses_count {get;}
public TwitterStatus status {get;}
public Texture2D profile_image {get;}
public Texture2D profile_background {get;}
public Color profile_background_color {get;}
public Color profile_text_color {get;}

Alternative image sizes for user profile images

Within the TwitterUserInfo you’ll find the profile_image_url and profile_image_url_https fields. These fields will contain the resized “normal” variant of the user’s uploaded image. This “normal” variant is typically 48px by 48px.

By modifying the URL, you can retrieve other variant sizings such as “bigger”, “mini”, and “original”. Consult the table below for more examples:

Variant Dimensions Example URL
normal 48px by 48px
bigger 73px by 73px
mini 24px by 24px
original original
Omit the underscore and variant to retrieve the original image. The images can be very 



Text sharing:

SPTwitter.instance.Post("Hello, I'am posting this from my app");


There is also a possibility to add image to the text message, the following snippet shows the example on how to post the message with game screenshot and listen for the post result:

SPTwitter.instance.OnPostingCompleteAction += OnPostingCompleteAction;

private IEnumerator PostScreenshot() {
    yield return new WaitForEndOfFrame();
	// Create a texture the size of the screen, RGB24 format
	int width = Screen.width;
	int height = Screen.height;
	Texture2D tex = new Texture2D( width, height, TextureFormat.RGB24, false );
	// Read screen contents into the texture
	tex.ReadPixels( new Rect(0, 0, width, height), 0, 0 );
	SPTwitter.instance.Post("My app ScreehShot", tex);

private	void OnPostingCompleteAction (TWResult result) {
	if(result.IsSucceeded) {
		Debug.Log("Congrats, you just posted something to twitter");
	} else {
		Debug.Log("Oops, post failed, something was wrong");


Full implementation can be found on Twitter example scene.