質問

Has anyone managed to successfully make HTTP requests from an Illustrator script (.jsx) and would be willing to share how?

I'm currently experimenting with CS3 on OS X, but CS4–5.5 would work as well.

I've found an example using Bridgetalk to utilize Bridge's socket connection, but couldn't get it to work so far.

Someone mentioned a wrapper around libcurl and also a simple bash script came to mind. Haven’t found much information on how to achieve either yet.

Any input/advice/hint would be highly appreciated!

役に立ちましたか?

解決

As it seems that this is a real edge case, here an outline of what I ended up doing. I’m planning on writing a blog post sometime about my solution, but it’s still very rough around the edges.

It seems that — for some strange reason — AI really doesn’t have any possibility to make HTTP requests while most other Adobe (CS) applications are able to do so. It turns out, though, that one can use a library called BridgeTalk (which comes with all CS apps) to facilitate communication between different applications.

BridgeTalk goes through Adobe’s Bridge app (as you might have guessed) and enables asynchronous (and synchronous, using a small trick) execution of serialized code.

Bridge comes with a web socket library which can be used to make requests to external servers. My AI script now goes through small custom API and HTTP wrappers and I ended up using the HTTP parser from the Extendables framework to deal with the response. For simplicity’s sake I’m forcing synchronous requests.

As an example, the API I ended up creating looks something like this (assuming an object foo with an attribute uuid):

function synchFoo(foo) {
    var options = {
        path  : '/api/foos/' + foo.uuid + 'sync',
        format: 'json',
        method: 'POST',
        host  : '127.0.0.1:3000',
        data  : fooDataToString(foo)
    }
    var response = bridgeHTTP.sendSynch(options);
    return JSON.parse(response.body);
}

This approach is the only thing I could get to work (across versions of AI) and is still fairly unstable and therefore not ready for publication. The project around this solution has been abandoned, though, so don’t hold your breath.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top