I am currently working on integrating the javascript API from change.org in order to retrieve all of my signed petitions for display on my source forge page. However, I am encountering an unauthorized request response from the change.org API.
Despite trying various approaches such as using api_secret and secret parameters, I consistently receive the 'unauthorized request' message.
Any advice or suggestions would be greatly appreciated :)
The javascript code I am using is as follows:
<html>
<head>
<title>change.org test</title>
<script type="text/javascript" src="./sha256.js"></script>
<script type="text/javascript" src="./changeorgapi.js"></script>
<script type="text/javascript">
function getAllPetitions() {
var client = new ChangeOrgApiClient({
"api_key" : "omitted for security",
"secret" : "omitted for security"
});
var user = new ChangeOrgApiUser(client);
user.setCallback(function(response) {
alert("message: " + JSON.stringify(response.getData()));
});
user.getSignedPetitions({
"user_id" : 31368676,
"fields" : "title,url,signature_count",
"page_size" : 5,
"page" : 1,
"sort" : "signatures_asc"
});
}
getAllPetitions();
</script>
</head>
<body>change.org test</body>
</html>