Implementing Feature

For using Twitter feature, you need to initialise the component first. You can do this by

//This should be the first call to use Twitter SDK
NPBinding.Twitter.Initialise()

Initialise , Login & Logout

After initialisation, you can login to twitter and can get a callback triggered once login process is finished.

Login
//This should be the first call to use Twitter SDK
NPBinding.Twitter.Initialise()

//Login to Twitter
NPBinding.Twitter.Login(CALL_BACK_METHOD);
Logout
NPBinding.Twitter.Logout();

Show Tweet Composer

This shows a Tweet composer and has options to share Message, URL and Image.

Tweet With Message
NPBinding.Twitter.ShowTweetComposerWithMessage(SHARE_MESSAGE, CALLBACK_METHOD);
Tweet With URL
NPBinding.Twitter.ShowTweetComposerWithLink(SHARE_MESSAGE, SHARE_URL, CALLBACK_METHOD);
Tweet With Image
NPBinding.Twitter.ShowTweetComposerWithImage(SHARE_MESSAGE, TEXTURE, CALLBACK_METHOD);
Tweet With Image
NPBinding.Twitter.ShowTweetComposerWithScreenshot(SHARE_MESSAGE, (eTwitterComposerResult _result)=>{
                    Debug.Log("Closed tweet composer");
                    Debug.Log("Result=" + _result);
                });

Request Logged-In Uuser Details

Request Login Details

NPBinding.Twitter.RequestAccountDetails(AccountDetailsRequestFinished);
private void AccountDetailsRequestFinished (TwitterUser _user, string _error)
{
    if (_error == null)
        Debug.Log("User info = " + _user + ".");
    else
        Debug.Log("Error : " + _error);
}

Request Email Id

NPBinding.Twitter.RequestEmailAccess(EmailAccessRequestFinished);
private void EmailAccessRequestFinished (string _email, string _error)
{
  if (_error == null)
      Debug.Log("Email id = " + _email + ".");
  else
    Debug.Log("Error : " + _error);
}

URL Requests for using Twitter 1.1 API

GET, POST, PUT, DELETE requests can be made and results can be retrieved by using below methods.

Example for a Get Request
//Make a GET request
string _URL         = "https://api.twitter.com/1.1/statuses/show.json";
IDictionary _params = new Dictionary<string, string>(){
{"id", "20"}
};

NPBinding.Twitter.GetURLRequest(_URL, _params, URLRequestFinished);

Callback Implementation


private void URLRequestFinished (object _responseData, string _error)
{
    Debug.Log(string.Format("Twitter request finished. Error= {0}.", _error.GetPrintableString()));

    if (_error == null)
        AppendResult("Response data = " + JSONUtility.ToJSON(_responseData) + ".");

    Debug.Log("Also, don't forget to check PostURLRequest, PutURLRequest, DeleteURLRequest");
}

results matching ""

    No results matching ""