brucealdridge / VendAPI

Class for accessing the api for vend on vendhq.com
Other
36 stars 22 forks source link

Can't seem to connect #13

Closed theBeachBoy closed 7 years ago

theBeachBoy commented 11 years ago

Trying your basic 3 line demo. When I put debug on, it crashed even inside the debug with message "Undefined index: request_header" that's on line 130 of VendRequest.php: echo $head.$this->curl_debug['request_header'].$foot.

it seems that the script dies at this line: $this->response = $response = curl_exec($this->curl); (returns false)

any ideas what I could be doing wrong?

theBeachBoy commented 11 years ago

Well I can't delete my "issue", but I found that when on localhost, you need to add this option: CURLOPT_SSL_VERIFYPEER => FALSE

could be useful for other people...

also one thing that could be nice would be to add "curl_error($this->curl)" to your debug as that's how I found out about the SSL issue, the debug was not working for me.

Thanks for your work, now I can use it!

chriswoodford commented 10 years ago

Ideally the curl request should have the following three options:

curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt ($this->curl, CURLOPT_CAINFO, $certificatePath);

where $certificatePath should point to a local version of this file: http://curl.haxx.se/ca/cacert.pem

setting CURLOPT_SSL_VERIFYPEER => FALSE is a quick and dirty solution, but not necessarily a secure solution that should be used for the long term