I like to use Google Apps Script, it is so convenient running it in the
cloud. Anyway, I think it is like javascript. I use these basic lines when
I want to use freeagent data:
Use some variables. type = the data you want, like projects, contacts,
invoices etc.
Change [TOKEN] in your OAUTH token.
the returned freeAgentData is an array of all data.
function freeagentGet(type, options) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var type = “projects”; // I have the variables to test, you can pass them
when calling the function ofcourse
var options = “?per_page=100”;
var response =
UrlFetchApp.fetch(“https://api.freeagent.com/v2/”+type+options,
{
headers: {
“Authorization”: “Bearer [TOKEN]”, “Accept”: “application/json”,
“contentType”: “application/json”}
} );
var freeAgentData = Utilities.jsonParse(response.getContentText()); //
return freeAgentData;
}
function freeagentPost(type, payload) {
var options =
{
“method” : “post”,
“payload” : payload,
“contentType” : “application/json”,
“headers” : {“Authorization”: “Bearer [TOKEN]”, “Accept”:
“application/json”}
};
var response = UrlFetchApp.fetch(“https://api.freeagent.com/v2/”+type,
options);
return response;
}Op maandag 31 december 2012 19:34:56 UTC+1 schreef Ossowalt het volgende:
Getting completely crazy. I tried any form of curl… Then got some PHP
sample but it doest work, or maybe there was some error in the server
configuration… It’s crazy a server must be involved in such this thing.
With API v1 was very easy, just matter of curl commands like this:
curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/company/users >users.xml
curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/contacts >contacts.xml
curl -u : -H ‘Accept: application/xml’ -H
‘Content-Type: application/xml’
https://.freeagentcentral.com/invoices >invoices.xml
Is there any way to accomplish the same with just some script commands?
Walter