I need to post data to a server. The server connection is made . But data is not posted in the server. I have correct script in curl/php. But its equivalent WWWform.Addfield is not working properly.
php script:
$oauth_consumer_key = 'mvKm39WrNkp4enY2Ufk5nnJ5qqoLoPkC';
$oauth_token = 'BYUTPDgspPDHiGcppXRtRqC7btBbKqGS';
session_start();
global $user;
$username = trim("visvanathan-a");
$password = trim(base64_encode("------@3620"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, 'http://10.98.12.54/sandbox/services/json?oauth_consumer_key='.$oauth_consumer_key.'&oauth_token='.$oauth_token.'');
$data = 'method="user.login"&username="'.$username.'"&password="'.$password.'"&domain="HCLTECH"';
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
$res = json_decode($result,true);
echo "Test Call ---- ";
print_r($res);
My equivalent unity Script
#pragma strict
import System.IO;
import System.Text;
import System;
private var str : String ="";
private var url = "http://10.98.12.54/sandbox/services/json?oauth_consumer_key=GGCbkzxLMCtwtCFjXPrjpdu98Xnj7QUy&oauth_token=xMZZMByTY5aL94ARqcASqEp4o7QEvKSz";
function Start ()
{
var form= new WWWForm();
form.AddField("method","user.login"+);
form.AddField("username","vigneshwari.ramu");
form.AddField("password","sasffgfhhhhj");
form.AddField("domain","HCLTECH");
var hs_post = WWW(url,form.data);
yield hs_post;
if(hs_post.error)
{
print("There was an error posting the high score: " + hs_post.error);
}
str = hs_post.text;
print(str);
}
Please say what problem in my unity code. why iam not able post username, password and domain