WebUtils.cs 931 B

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. public class WebUtils
  4. {
  5. public static Dictionary<string, string> ParseParametersFromQueryString(string s)
  6. {
  7. Dictionary<string, string> results = new Dictionary<string, string>();
  8. int questionMarkIndex = s.IndexOf('?');
  9. //event if it is -1, continue to try parsing the parameters since facebook on android doesn't send a URL,
  10. //doesn't even send a question mark, but only the parameters
  11. string parametersString = s.Substring(questionMarkIndex + 1);
  12. string[] keyValuesStrings = parametersString.Split('&');
  13. foreach (string keyValueString in keyValuesStrings)
  14. {
  15. string[] keyValuePair = keyValueString.Split('=');
  16. //Make sure there is a key AND a value
  17. if (keyValuePair.Length == 2)
  18. {
  19. string key = WWW.UnEscapeURL(keyValuePair[0]);
  20. string value = WWW.UnEscapeURL(keyValuePair[1]);
  21. results[key] = value;
  22. }
  23. }
  24. return results;
  25. }
  26. }