Showing Posts For RobbyT.1925:

Forum for new developers

in API Development

Posted by: RobbyT.1925

RobbyT.1925

I figured I’d start a forum for new developers who are having specific issues with the v2 API. This is not for general programming questions, it’s specifically for getting help with issues that have something to do with using the API. To get started, here’s an issue I’m having.

I’m trying to return the array of characters on my account, yet all I’m getting is the array of API versions. Can anyone explain where I’m going wrong and how to fix it?

window.onload = function(){
	function createCORSRequest(method, url){
		var request = new XMLHttpRequest();
		if("withCredentials" in request){
			request.open(method, url, true);
		}
		else if(typeof XDomainRequest != "undefined"){
			request = newXDomainRequest();
			request.open(method, url);
		}
		else{
			request = null;
		}
		return request;
	}
	
	function makeCORSRequest(){
		var key = API Key;
		var url = "https://api.guildwars2.com?access-token=<" +key +">/v2/account";
		//var url = "https://api.guildwars2.com";
		var request = createCORSRequest("GET", url);
		if(!request){
			alert("CORS not supported");
			return;
		}
		
		request.onload = function(){
			var text = request.responseText;
			document.write(text);
			alert(text);
		}
		
		request.onerror = function(){
			alert("Error");
		}
		
		//request.setRequestHeader("Authorization", "Bearer<68ADC137-8DB1-904C-BEA3-7F4F09458405109C9565-8B0F-43B6-9154-A3C1BF80962C>");
		request.send();
	}
	
	makeCORSRequest();
}

(edited by RobbyT.1925)

Any good tutorials on how to use the API?

in API Development

Posted by: RobbyT.1925

RobbyT.1925

I have a question maybe someone can answer. If I wanted to create a website, say for a guild. Does the API interface with Javascript? I know the API is service based, so I honestly don’t see this being a problem.