Skip to content

Instantly share code, notes, and snippets.

@cogwirrel
Created June 1, 2015 00:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cogwirrel/07f67c07ff2ffefecd59 to your computer and use it in GitHub Desktop.
Save cogwirrel/07f67c07ff2ffefecd59 to your computer and use it in GitHub Desktop.
TuGo SMS Backup
var backup = function(options) {
$.ajax({
url: "https://api-gb.tugoapp.com/users/me/history?from_version=0&page_size=" + options.numTexts + "&page_number=1&with_source=" + options.theirNumber + "," + options.myNumber + "&with_destination=" + options.theirNumber + "," + options.myNumber,
headers: {
"X-External-Transaction-Id": "blahblah123",
"Authorization": "Bearer " + options.token,
"X-User-Version": "1.2.0",
"X-Country-Code": "GB",
"X-User-Msisdn": options.myNumber,
"Accept-Language": "en-GB,en-US;q=0.8,en;q=0.6",
"X-User-Agent":options.xUserAgent
}
}).success(options.callback);
};
// Log in to https://go.tu.com/ and look at the request headers used to get the values of 'token' and 'xUserAgent'
// -- In Chrome: right click -> inspect element -> network -> history?...
// Then copy and paste everything into the console and see your message backup!
backup({
numTexts: 10000,
myNumber: "447777112233",
theirNumber: "447777445566",
token: "This should the long oauth token string. Copy the <token> part of the 'Authorization: Bearer <token>' header and paste it here!",
xUserAgent: "Paste the contents of the X-User-Agent header in here!",
callback: function(response) {
console.log(response);
}
});
@noahlucci
Copy link

Hi cogwirrel,

Thank you for posting this! I'm looking to export my messages from TuGo and this looks like the perfect solution.

I'm not very experienced with JavaScript, and wondered whether you could help use your code.

Am I meant to paste it all into the "JavaScript Console"? If so, do I need to change of the first section (before "//Log in to...")?

I've found the request headers. Just so I'm clear, should the "token" start with "Bearer", and should the xUserAgent be "GConnect/XX.X.XX"?

When I run it in the Console I get an error message - "Uncaught SyntaxError: Invalid or unexpected token" - referencing "myNumber", so I'm just trying to find the flaw!

Thanks so much for your help - I really appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment