Open HubSpace2000 opened 7 years ago
At 18:07 GMT the api works well
The login endpoint for the website is https://auth.iqoption.com/api/v1.0/login. I haven't used nor worked on this API in a long time so I'm not sure.
Are you receiving a 404 error visiting it in a browser or through the API wrapper?
by using the browser
This is in Java code, but quite clear and working.
The initial login is via a https post. the cookie ssid is used to keep the login alive, then we upgrade our https connection to a wss connection.
The following relates to the https URL's.
// precedes a comment in java. ; ends the code to run/line
// List of url's in use
private static final String url = "https://iqoption.com"; // base site
private static final String urlLogin = url + "/api/login"; // use https POST to login
private static final String urlGetProfile = url + "/api/getprofile"; // use https GET
private static final String urlChangeBalance = url + "/api/profile/changebalance"; // use https GET
when using this python coded api, use-
api = IQOptionAPI("iqoption.com", "yourLoginEmail", "yourPassword") api.connect()
Hey @MadOne199 , i just converted your source to c#
` HttpWebRequest request = WebRequest.Create("https://iqoption.com/api/login") as HttpWebRequest; request.Method = "POST";
string _auth = string.Format("{0}:{1}", "demo@myemail.com", "mydemopass");
string _enc = Convert.ToBase64String(Encoding.ASCII.GetBytes(_auth));
string _cred = string.Format("{0} {1}", "Basic", _enc);
request.Headers[HttpRequestHeader.Authorization] = _cred;
request.ContentType = "application/json";
var httpResponse = (HttpWebResponse)request.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
Response.Write(result);
}
`
But it returns {"isSuccessful":false,"message":{"email":["E-mail \"\" is not valid"],"password":["Invalid password length"]},"result":[]}
Can you please help me why this response returns?
Can’t help with C# sorry. Never used it. The response indicates you are not using your real login email and password so check that first. I am of course assuming you have an account. I also don’t see where the post is being made ie iqoption.com or eu.iqoption.com? The fact that you have a response shows that you are nearly there. Not at a computer so sorry cannot be more helpful.
I read it all this time, I cannot see anything obvious and cannot try the code just now. 1/. The response says email and password incorrect. Check these values by a manual login via a web browser 2/ you are using http biut the site is https.
I know it may sound daft, but I had similar response and it was down to me using an incorrect password. Please note that I only used this code to see how to do it. I don’t use the python code.
If still stuck at the weekend ask again and I will try to help
Did you already solve the problem? I have the same issue and don't know why... @MadOne199 I tried to login manually --> works fine and http or https does not change the problem...
@HubSpace2000 Thats the default response if the post data is missing from the request.
@MadOne199 @SiliconDare You don't need to use the Authorization Header, you're not requesting a network authorization. Your content type is also wrong. Post the email address and password in the request stream. The following should work fine. Cheers!
HttpWebRequest HTTPRequest = WebRequest.Create("https://iqoption.com/api/login") as HttpWebRequest;
var PostData = Encoding.ASCII.GetBytes("email=example@example.com&password=eXaMpL3");
HTTPRequest.Method = "POST";
HTTPRequest.ContentType = "application/x-www-form-urlencoded";
HTTPRequest.ContentLength = PostData.Length;
using (var HTTPStream = HTTPRequest.GetRequestStream())
{
HTTPStream.Write(PostData, 0, PostData.Length);
}
var HTTPResponse = (HttpWebResponse)HTTPRequest.GetResponse();
using (var HTTPResponseStream = new StreamReader(HTTPResponse.GetResponseStream()))
{
var HTTPResponseString = HTTPResponseStream.ReadToEnd();
MessageBox.Show(HTTPResponseString);
}
@n1nj4z33 I think this issue can be closed now?
@HubSpace2000 Thats the default response if the post data is missing from the request.
@MadOne199 @SiliconDare You don't need to use the Authorization Header, you're not requesting a network authorization. Your content type is also wrong. Post the email address and password in the request stream. The following should work fine. Cheers!
HttpWebRequest HTTPRequest = WebRequest.Create("https://iqoption.com/api/login") as HttpWebRequest; var PostData = Encoding.ASCII.GetBytes("email=example@example.com&password=eXaMpL3"); HTTPRequest.Method = "POST"; HTTPRequest.ContentType = "application/x-www-form-urlencoded"; HTTPRequest.ContentLength = PostData.Length; using (var HTTPStream = HTTPRequest.GetRequestStream()) { HTTPStream.Write(PostData, 0, PostData.Length); } var HTTPResponse = (HttpWebResponse)HTTPRequest.GetResponse(); using (var HTTPResponseStream = new StreamReader(HTTPResponse.GetResponseStream())) { var HTTPResponseString = HTTPResponseStream.ReadToEnd(); MessageBox.Show(HTTPResponseString); }
@n1nj4z33 I think this issue can be closed now?
I needed to change the login url to the updated v1.0 and is working fine It returns a session id something like this {"data":{"ssid":"90ab03c2e4ee732b3581ca9420f09c99"}}
But after this response how to get profile. The success url to retrieve profile is https://iqoption.com/api/getprofile but it returns {"isSuccessful":false,"message":"Not logged in","result":[]}
It’s been an year since I tried this, but from what I remember I was using the above code with a Cookie Container and WebSocket requests. Did you try the above code? What was in the JSON result?
It’s been an year since I tried this, but from what I remember I was using the above code with a Cookie Container and WebSocket requests. Did you try the above code? What was in the JSON result?
I already mentioned above that the login works fine and returns a ssid but having problem to get profile
How do you find all these urls?
@HubSpace2000 Thats the default response if the post data is missing from the request.
@MadOne199 @SiliconDare You don't need to use the Authorization Header, you're not requesting a network authorization. Your content type is also wrong. Post the email address and password in the request stream. The following should work fine. Cheers!
HttpWebRequest HTTPRequest = WebRequest.Create("https://iqoption.com/api/login") as HttpWebRequest; var PostData = Encoding.ASCII.GetBytes("email=example@example.com&password=eXaMpL3"); HTTPRequest.Method = "POST"; HTTPRequest.ContentType = "application/x-www-form-urlencoded"; HTTPRequest.ContentLength = PostData.Length; using (var HTTPStream = HTTPRequest.GetRequestStream()) { HTTPStream.Write(PostData, 0, PostData.Length); } var HTTPResponse = (HttpWebResponse)HTTPRequest.GetResponse(); using (var HTTPResponseStream = new StreamReader(HTTPResponse.GetResponseStream())) { var HTTPResponseString = HTTPResponseStream.ReadToEnd(); MessageBox.Show(HTTPResponseString); }
@n1nj4z33 I think this issue can be closed now?
hi, someone can help me? Hi, i have tried this code but i couldn't make it work. i am receiving a 404 error! I have tryed two URLs: https://iqoption.com/api/v1.0/login and https://iqoption.com/api/login.
ok. i got it! the correct url is "https://auth.iqoption.com/api/v1.0/login"
thanks
Hello , its seem IQ have changed the http login url any idea please? thx you