Frage

I am trying to send a server "schooltraq.com/api/" variables for a request. My Code:

package
{
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.*;

    public class tester extends MovieClip
    {
        private var url:String = "http://schooltraq.com/api/";
        var loader:URLLoader = new URLLoader();
        public function tester()
        {
            getAssignments();
        }
        private function getAssignments()
        {
            var request:URLRequest = new URLRequest(url);
            request.method = URLRequestMethod.POST;
            var vars:URLVariables = new URLVariables();

            vars.type = "get";
            vars.request = "assignmentlist";

            request.data = vars;
            trace(request.data);        

            loader.addEventListener(Event.COMPLETE, on_complete);
        }
        private function on_complete(e:Event):void
        {
            trace(loader.data);
        }
    }
}

How ever when I keep getting back "error:empty request". I emailed the site owner and he said that my program may be dropping the data during redirects. Any idea how to fix that? Their api is http://help.schooltraq.com/kb/schooltraq-api/an-overview-of-the-schooltraq-api. Any help would be appreciated greatly.

War es hilfreich?

Lösung

this is Brandon Wang (founder + lead developer at Schooltraq), thanks for using our API.

To resolve the problem, while I can't really provide any specifics because I don't know how ActionScript works, here are some things that may help you:

  1. Try sending the request to http://beta.schooltraq.com/api and see if the request completes then. We're using a Permanent Redirect to point people from schooltraq.com/api to the beta.schooltraq one. The reason we advise for this redirect is simply because the API endpoint may be moved around. We're sorry if this is causing problems :(

  2. Are you sure you're running a POST request? Sometimes people run GET requests and the API really isn't set up for that. It does look like you're running a POST request from your code, though, so I'm not completely sure.

  3. In the code above, you're also not sending along any API key, which is required for GET ASSIGNMENTLIST.

I hope this helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top