I can easily create a message from bash shell utilizing the curl method described in the basecamp api docs. However, my app is not written in php so I'd like to be able to access the basecamp sever via a basic ajax post. Unfortunately, I don't seem to be able to translate the curl statement into the ajax post. I though this would suffice:
function callBasecamp() {
var parameters = {
user:"[my_basecamp_username]",
pass:"[my_basecamp_password]",
userAgent: '[my_app] (my_email)',
contentType: 'application/json; charset=utf-8',
data: ({ "subject": "This is a Test Message", "content": "This is test content. Please disregard if notified." }),
};
var data = JSON.stringify(parameters);
$.ajax({
type: "POST",
data: data,
dataType: 'json',
url: "../../../../site_media/proxy.php?url=https://basecamp.com/[account_id#]/api/v1/projects/[project#]/messages.json?" + data,
traditional: true,
success: function(data){
console.log(data);
}
});
}
but though my dev server returns an HTTP 200 216 response, basecamp doesn't create the message and I don't see any returned data. I am using a php proxy to circumvent django csrf issues:
proxy.php
<?php
// File Name: proxy.php
if (!isset($_POST['url'])) die();
$url = urldecode($_POST['url']);
$url = 'https://' . str_replace('https://', '', $url); // Avoid accessing the file system
echo file_get_contents($url);
any ideas on where my difficulty might be?