Skip to content

Instantly share code, notes, and snippets.

@ayutaz
Created December 24, 2019 17:26
Show Gist options
  • Save ayutaz/3fbec9ecdbaa80723779632f6b32cf95 to your computer and use it in GitHub Desktop.
Save ayutaz/3fbec9ecdbaa80723779632f6b32cf95 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Twity.DataModels.Responses;
public class EventHandler : MonoBehaviour {
    private config key;
    void Start () {
        key = GameObject.Find("Config").GetComponent<config>();
        Twity.Oauth.consumerKey       = key.GetConsumerKey();
        Twity.Oauth.consumerSecret    = key.GetConsumerSecret();
        Twity.Oauth.accessToken       = key.GetAccessToken();
        Twity.Oauth.accessTokenSecret = key.GetAccessTokenSecret();
        Dictionary<string, string> parameters = new Dictionary<string, string>();
        parameters ["q"] = "悠遠物語";
        parameters ["count"] = 30.ToString();;
        StartCoroutine (Twity.Client.Get ("search/tweets", parameters, Callback));
    }
    void Callback(bool success, string response) {
        if (success) {
            SearchTweetsResponse Response = JsonUtility.FromJson<SearchTweetsResponse> (response);
            // Debug.Log(Response.statuses[2].text);
            for(int i = 0;i <Response.statuses.Length;i++){
                string text = Response.statuses[i].text;
                Debug.Log(text);
            }
        } else {
            Debug.Log (response);
        }
    }
}
@ayutaz
Copy link
Author

ayutaz commented Dec 24, 2019

再書

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment