本文整理汇总了C#中WWWForm.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# WWWForm.ToString方法的具体用法?C# WWWForm.ToString怎么用?C# WWWForm.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WWWForm
的用法示例。
在下文中一共展示了WWWForm.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadLevelInfo
string uploadLevelBlockUrl = "http://www.jun610.com/ourway/levelRecordings/levelBlockUpload.php"; //be sure to add a ? to your url
#endregion Fields
#region Methods
public IEnumerator UploadLevelInfo(string levelID, string mapBlocks)
{
//CancelInvoke("DoRecord");
int lvVer = PlayerPrefs.GetInt("currentVersion");
string levelInfo = levelID + "_" + lvVer.ToString();
WWWForm form = new WWWForm();
form.AddField("action","saveLevel");
form.AddField("lvID", levelInfo);
// form.AddField("content",mapBlocks);
string s = mapBlocks;
string[] itemSet = s.Split('/');
string blocks = "";
foreach(string i in itemSet){
if (i.Length <= 0 ){
break;
}
blocks += "|" + i;
}
form.AddField("blockID", blocks);
// string objName = " ";
// string index = " ";
// string locString = " ";
//
// foreach(string i in itemSet){
// if (i.Length <= 0){
// break;
// }
// string[] subItemSet = i.Split('_');
// objName += subItemSet[0];
// index += subItemSet[1];
// string locxy = subItemSet[2];
// string[] xy = locxy.Split(',');
// locString += xy[0] + "-" + xy[1];
//
// }
//
// form.AddField("blockPos", locString);
// form.AddField("blockType",objName);
// form.AddField("blockID",index);
//form.AddField("metrics", inMetrics.ToString() ); //this could be from Player Settings
//form.AddField ("name", inID);
WWW w = new WWW(uploadLevelBlockUrl,form);
yield return w;
if (w.error != null) {
Debug.Log(w.error);
} else {
Debug.Log ("Successful Upload!");
Debug.Log (w.text + "\n\n" + form.ToString());
}
}
示例2: GetUserByKey
//<summary>
// Register the DeviceID if not exist
//</summary>
// <param name="userId">Device Id</param>
// <param name="userLang">Device current lang</param>
public IEnumerator GetUserByKey(string userId, string userLang)
{
string requestQueryUser = URL + GET_USER_METHOD;
if(userLang.Equals("English")){
userLang = "en";
}
else if(userLang.Equals("Spanish")){
userLang = "es";
}
//Debug.Log(">>>>> GetUserByKey() " + requestQueryUser);
WWWForm requestForm = new WWWForm();
requestForm.AddField ("appid", APP_ID);
requestForm.AddField ("keyid", userId);
requestForm.AddField ("userlang", userLang);
requestForm.AddField ("seckey", "");
WWW queryUserResponse = new WWW(requestQueryUser, requestForm);
yield return queryUserResponse;
if (!string.IsNullOrEmpty(queryUserResponse.error)) {
Debug.Log (string.Format ("User Not Found or Empty {0}", queryUserResponse.error));
}
else {
Debug.Log("queryUserResponse: " + queryUserResponse.text);
JSONObject json = new JSONObject(queryUserResponse.text);
//AccessData(json);
if(!json.type.Equals(JSONObject.Type.STRING)){
try{
string stringObj = json.list[4].list[0].str;
Debug.Log("json.list[4].list[0].str" + json.list[4].list[0].str);
if(stringObj.Equals("OK")){
Debug.Log("User already registered");
}
}
catch(Exception ex){
Debug.Log("GetUserByKey:ex " + ex);
}
}
else{
Debug.Log("Registering user...");
string requestRegisterURL = URL + REGISTER_USER_METHOD;
JSONObject jsonParams = new JSONObject(JSONObject.Type.OBJECT);
jsonParams.AddField("appid", APP_ID);
jsonParams.AddField("keyid", userId);
jsonParams.AddField("UserLang", userLang);
string seckey = generateSecurityKey(requestRegisterURL, jsonParams);
//Debug.Log("App_id: " + APP_ID + " keyid: " + userId + " userLang: " + userLang + " seckey: " + seckey.Trim());
//Debug.Log (">>>>>(seckey) GetUserByKey: " + seckey.Trim());
WWWForm requestRegisterForm = new WWWForm();
requestRegisterForm.AddField ("appid", APP_ID); //APP_ID
requestRegisterForm.AddField ("keyid", userId); //userId
requestRegisterForm.AddField ("UserLang", userLang);
requestRegisterForm.AddField ("seckey", seckey.Trim());
Debug.Log("ws response: " + requestRegisterForm.ToString());
WWW registerUserResponse = new WWW(requestRegisterURL, requestRegisterForm);
yield return registerUserResponse;
//Debug.Log(registerUserResponse.ToString());
if (!string.IsNullOrEmpty(registerUserResponse.error)) {
Debug.Log("Error Null Or Empty " + registerUserResponse.error);
}
else {
Debug.Log("User Registration OK " + registerUserResponse.text);
}
}
}
}