// grab your spreadsheet's ID / "key" from the URL to access your doc...
    // e.g. everything after "key=" in the URL: https://docs.google.com/spreadsheet/ccc?key=0Ak-N8rbAmu7WdGRFdllybTBIaU1Ic0FxYklIbk1vYlE
    // make sure stop as soon as you hit an ampersand, those are additional URL parameters we don't need
    public static ListFeed GetSpreadsheet(string spreadsheetID)
    {
        // We need this fake certificate to trick Mono's security to use HTTPS... doesn't work in webplayer's security sandbox
        InsecureSecurityCertificatePolicy.Instate();

        var service = new SpreadsheetsService("UnityConnect");

        var listQuery = new ListQuery("https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/default/public/values");

        return(service.Query(listQuery));
    }
Beispiel #2
0
    // grab your spreadsheet's ID / "key" from the URL to access your doc...
    // make sure stop as soon as you hit an ampersand, those are additional URL parameters we don't need
    public static ListFeed GetSpreadsheet(string spreadsheetID, int gridId)
    {
        // We need this fake certificate to trick Mono's security to use HTTPS... doesn't work in webplayer's security sandbox
        InsecureSecurityCertificatePolicy.Instate();

        SpreadsheetsService service = new SpreadsheetsService("UnityConnect");

        string    url       = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/" + gridId + "/public/values";
        ListQuery listQuery = new ListQuery(url);

        ListFeed feed = service.Query(listQuery);

        return(feed);
    }
Beispiel #3
0
    public static SpreadsheetListFeed GetSpreadsheetContents(string spreadsheetID, string sheetID)
    {
        InsecureSecurityCertificatePolicy.Instate();

        SpreadsheetListFeed listFeed = null;
        string         json          = "";
        string         url           = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/" + sheetID + "/public/basic?alt=json";
        HttpWebRequest request       = (HttpWebRequest)HttpWebRequest.Create(url);

        try {
            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
                using (StreamReader reader = new StreamReader(response.GetResponseStream())) {
                    json = reader.ReadToEnd();
                }
            }
//			Debug.Log(string.Format("Response from {0}\n{1}", url, json));
            listFeed = JsonMapper.ToObject <SpreadsheetListFeed>(json);
        }catch (Exception e) {
            Debug.LogWarning("Failed to read spreadsheet: " + spreadsheetID + " " + e.Message);
            listFeed = null;
        }

        return(listFeed);
    }