12345678910111213141516171819202122232425262728293031 |
- using UnityEngine;
- using System.Collections.Generic;
- public class WebUtils
- {
- public static Dictionary<string, string> ParseParametersFromQueryString(string s)
- {
- Dictionary<string, string> results = new Dictionary<string, string>();
- int questionMarkIndex = s.IndexOf('?');
- //event if it is -1, continue to try parsing the parameters since facebook on android doesn't send a URL,
- //doesn't even send a question mark, but only the parameters
- string parametersString = s.Substring(questionMarkIndex + 1);
- string[] keyValuesStrings = parametersString.Split('&');
- foreach (string keyValueString in keyValuesStrings)
- {
- string[] keyValuePair = keyValueString.Split('=');
- //Make sure there is a key AND a value
- if (keyValuePair.Length == 2)
- {
- string key = WWW.UnEscapeURL(keyValuePair[0]);
- string value = WWW.UnEscapeURL(keyValuePair[1]);
- results[key] = value;
- }
- }
- return results;
- }
- }
|