I really appreciate response from fellow members and for the right one, even pay for your time.
I got this code, from a developer who does not know anything about zennoposter:
Even I run this code in project maker I will receive the following error:
"} expected". [Row: 6; Column: 19]
"Invalid token 'namespace' in class, struct, or interface member declaration". [Row: 8; Column: 1]
"Invalid token '{' in class, struct, or interface member declaration". [Row: 9; Column: 1]
"A namespace cannot directly contain members such as fields or methods". [Row: 107; Column: 1]
"Type or namespace definition, or end-of-file expected". [Row: 109; Column: 1]
"Type or namespace definition, or end-of-file expected". [Row: 110; Column: 1]
Can anyone help me fix this? Please.
-MT
I got this code, from a developer who does not know anything about zennoposter:
Код:
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
namespace MerInfo
{
class CallMerInfo
{
private string _uniqid;
private string _csrfcookiename;
private CookieContainer _cookieJar;
private string _returnedresponse;
private string GetRawResponse(string who, string location)
{
_returnedresponse = "";
var uri = "http://www.merinfo.se/search?who=" + who + "&location=" + location;
Getcsrfcookiename(uri);
var request = WebRequest.Create(uri);
request.Method = "POST";
var postData = "";
var byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
var dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
var response = request.GetResponse();
dataStream = response.GetResponseStream();
if (dataStream != null)
{
var reader = new StreamReader(dataStream);
var responseFromServer = reader.ReadToEnd();
var positionstart = responseFromServer.IndexOf("'uniqid': '", System.StringComparison.Ordinal);
var positionend = responseFromServer.IndexOf("',", positionstart + 11, System.StringComparison.Ordinal);
_uniqid = responseFromServer.Substring(positionstart + 11, positionend - (positionstart + 11));
reader.Close();
}
if (dataStream != null) dataStream.Close();
response.Close();
uri = "http://www.merinfo.se/ajax/search";
postData = "uniqid=" + _uniqid + "&csrf_test_name=" + _csrfcookiename;
GetSecondResponse(uri, postData);
return _returnedresponse;
}
private void Getcsrfcookiename(string uri)
{
_cookieJar = new CookieContainer();
var request = (HttpWebRequest)WebRequest.Create(uri);
request.CookieContainer = _cookieJar;
var response = request.GetResponse();
foreach (var c in from Cookie c in _cookieJar.GetCookies(request.RequestUri) where c.Name.ToString(CultureInfo.InvariantCulture) == "csrf_cookie_name" select c)
{
_csrfcookiename = c.Value.ToString(CultureInfo.InvariantCulture);
}
}
private void GetSecondResponse(string uri, string postData)
{
var request = (HttpWebRequest)WebRequest.Create(uri);
request.CookieContainer = _cookieJar;
request.Method = "POST";
var byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
var dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
var response = request.GetResponse();
dataStream = response.GetResponseStream();
if (dataStream != null)
{
var reader = new StreamReader(dataStream);
var responseFromServer = reader.ReadToEnd();
_returnedresponse = "";
_returnedresponse = @"HTTP/" + ((HttpWebResponse)response).ProtocolVersion.Major.ToString() + @"." + ((HttpWebResponse)response).ProtocolVersion.Minor.ToString() + @" " + ((HttpWebResponse)response).StatusDescription + Environment.NewLine;
_returnedresponse += response.Headers.ToString();
_returnedresponse += responseFromServer;
//_returnedresponse = responseFromServer.Replace(",", "," + Environment.NewLine);
reader.Close();
}
if (dataStream != null) dataStream.Close();
response.Close();
}
}
}
"} expected". [Row: 6; Column: 19]
"Invalid token 'namespace' in class, struct, or interface member declaration". [Row: 8; Column: 1]
"Invalid token '{' in class, struct, or interface member declaration". [Row: 9; Column: 1]
"A namespace cannot directly contain members such as fields or methods". [Row: 107; Column: 1]
"Type or namespace definition, or end-of-file expected". [Row: 109; Column: 1]
"Type or namespace definition, or end-of-file expected". [Row: 110; Column: 1]
Can anyone help me fix this? Please.
-MT