I can not log in to MyStore with REST features.

$urlrest = 'https://online.moysklad.ru/exchange/rest'; if ($ch = curl_init($urlrest) ) { curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,'ХХХХ:ХХХХХ'); $res = curl_exec($ch); curl_close($ch); echo $res; 

Closed due to the fact that off-topic by the participants of Kromster , default locale , andreymal , 0xdb , LFC May 29 at 20:13 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Kromster, default locale, andreymal, 0xdb, LFC
If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    Browser tried to go to the specified address? Apparently not, because they saw that it requires authentication (and you need to authorize, but the code does not have a name and password ... it will not take it from the air). That is, if I remember php correctly, I need a string like

     curl_setopt($ch, CURLOPT_USERPWD, $auth_name.':'.$auth_pass); 
    • No, I tried ... after adding a line, I began to return a 413 error. although it should return 404 - crymaks
    • curl_setopt ($ ch, CURLOPT_POST, 1) solved the problem; it was necessary to change 1 to 0 - crymaks
    • Look for the documentation - there it should all be described. And just to guess - post or get - is very difficult. - KoVadim
    • I just read it, all by curl and the MoiSklad API itself - crymaks