###前提・実現したいこと
UnityWebRequestを使いUnity内でAPIから位置情報データを取得し格納する
###発生している問題・エラーメッセージ
書いているプログラムで合っているのわからない
###該当のソースコード
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.Networking; 5using Newtonsoft.Json; 6using System.Net; 7using System.Linq; 8 9public class api : MonoBehaviour { 10 11 // Use this for initialization 12 void Start () { 13 StartCoroutine(GetArea()); 14 } 15 IEnumerator GetArea() 16 { 17 18 var parm = new Dictionary<string, object>(); 19 parm["type"] = 1; 20 parm["count"] = "5000"; 21 parm["format"] = "json"; 22 23 UnityWebRequest request = UnityWebRequest.Get("https://maps.googleapis.com/maps/api/place/nearbysearch/json"); 24 25 yield return request.Send(); 26 27 if (request.isError) 28 { 29 Debug.Log(request.error); 30 } 31 else 32 { 33 if(request.responseCode == 200) 34 { 35 //UTF8文字列として取得する 36 string text = request.downloadHandler.text; 37 38 //バイナリデータとして取得する 39 byte[] results = request.downloadHandler.data; 40 } 41 } 42 } 43 44 // Update is called once per frame 45 void Update () { 46 47 } 48} 49
###追記
プログラム初心者でAPIを初めて触るので、普段から触っている人からしたら意味不明なプログラムかもしれませんので、ぜひ参考になるプログラムなどを教えていただければ幸いです。
###補足情報
Unity 5.5.2f1
VisualStudio 2015
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。