API3
mateuszp at July 17th, 2015 05:21 — #1
Hello,
I have an issue with authorizing in the system using API3. I am using PHP with cURL. The code looks like this:
$data = array(
'login'=>$this->user,
'password'=>$this->password
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
//Some more CURL options irrelevant for this example
$output = curl_exec($ch);
curl_close($ch);
Once I try to connect to the API I am getting the following response:
Invalid request data: 795: unexpected token at '------------------------------7e8482755063
Content-Disposition: form-data; name="login"
------------------------------7e8482755063
Content-Disposition: form-data; name="password"
------------------------------7e8482755063--
(I replaced username and password with asterisks)
Anyone knows what I'm doing wrong?
best regards,
Mateusz P
pete_onepagecrm at July 17th, 2015 06:22 — #2
@mateuszp have you seen this code sample? It should help you get through the signing process.
@PawelSmolinski is our resident PHP expert. He's working on a client at the moment which you can see here - https://packagist.org/packages/zipoking/onepagecrm-php-client
I'm not sure what the status of this package is but I'll ask him to post here on Monday.
mateuszp at July 17th, 2015 06:25 — #3
Hello,
Thank you for a fast reply. I haven't seen it, thank you for this. I also just realized 5 minutes ago that I have to pass data as a JSON string. Now it works.
Regards,
Mateusz Piatkowski
pete_onepagecrm at July 17th, 2015 09:12 — #4
good stuff - For some reason the PHP sample was removed from our docs page.
Hopefully the PHP client will be useful for you.
Just get in touch if you have any other questions.
Powered by Discourse, best viewed with JavaScript enabled