On Thu, Dec 13, 2012 at 6:40 PM, Hunter <
hun...@stonegiantlabs.com> wrote:
> Howdy,
>
> I'm trying to use curl to communication with the Less Accounting API, but
> i'm doing something wrong as I keep getting the error "Couldn't authenticate
> you". I created my api key in my LA account. Here is my code:
>
>> $less_api_key = "<key redacted>";
>>
>> $less_biz_name = "<biz subdomain>";
>>
>> $post_values = "";
>> $post_values .= "expense[title]=".$acct_info['payee']."&";
>> $post_values .= "expense[notes]=".$acct_info['description']."&";
>> $post_values .= "expense[amount]=".$acct_info['amount']."&";
>> $post_values .= "expense[paid_date]=".$acct_info['date']."&";
>> $post_values .= "expense[check_number]=".$acct_info['ref']."&";
>> $post_values .= "expense[is_paid]=0&"; //default to not paid
>> $post_values .= "api_key=".$less_api_key."";
>>
>>
>>
>> $post_url = "https://$
less_biz_name.lessaccounting.com/expenses.xml";
>> $ch = curl_init($post_url);
>> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
>> curl_setopt($ch, CURLOPT_POSTFIELDS, $post_values);
>> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
>> $result_page = curl_exec($ch);
>> curl_close($ch);
>> var_dump($result_page);
>
>
> Any help would be greatly appreciated!
You also have to supply your username and password and use basic auth.
cheers,
steven bristol