A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: [RESOLVED] URLRequest to remote server

  1. #1
    Member
    Join Date
    Apr 2007
    Posts
    93

    resolved [RESOLVED] URLRequest to remote server

    Can I send and load variables to a php script on a different server? Hen I try I get a Error #2048: Security sandbox violation

    How do I get around this?

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    If you control the other server, you can put up a crossdomain.xml file which allows access from the first server.

    If not, you cannot, directly. You could use a local php proxy, but if you do so, be sure to limit it to the urls you're trying so that it cannot be used as an open proxy.

  3. #3
    Member
    Join Date
    Apr 2007
    Posts
    93
    How do I set that up? I have a server that I have full access to, but the one that has my scripts on it is just a web hosting account.

    What can I do to make this work. I cant get php installed on my Webserver because of x32 and x64 conflicts.

    And I dont know enough about ASP to re-write my php...

    Need help. If you can tell me a good resource that will teach me to convert my PHP to ASP I can host it all on one server...

    Im stressing out.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    So, to be clear:
    Webserver A has your flash, is an ASP server which you have full access to.
    Webserver B has the php scripts you want to access, you do not have full access.

    If you can place a file at the root of webserver B, like http://webserverb/crossdomain.xml , then you can solve it that way.

    Otherwise, I suggest writing a passthrough script in ASP to call the php resource on the other server and return data. That will appear to the swf as if everything is coming from the same server.

  5. #5
    Member
    Join Date
    Apr 2007
    Posts
    93
    Things are starting to become more clear. I will try the crossdomain first in the root directory, but if that doesnt work, how do I write the passthrough script?

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I don't know ASP, so I can't answer that. I assume there's some server-side way of making a url request and sending the response back to the client.
    Last edited by 5TonsOfFlax; 06-02-2009 at 02:17 AM.

  7. #7
    Member
    Join Date
    Apr 2007
    Posts
    93
    I have my SWF embeded on a site hosted on my webserver:

    PHP Code:
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://macromedia.com/cabs/swflash.cab#version=6,0,0,0"
    ID=flaMovie WIDTH=475 HEIGHT=270>
    <
    PARAM NAME=movie Value="http://www.zetapsioshawa.org/handicap/final/handicapV2.swf?clientEmail=email@server.com&customerEmail=email@server.com">
    <
    PARAM NAME=quality VALUE=medium>
    <
    EMBED src="http://www.zetapsioshawa.org/handicap/final/handicapV2.swf?clientEmail=email@server.com&customerEmail=email@server.com"  WIDTH=475 HEIGHT=270 TYPE="application/x-shockwave-flash"
    </
    EMBED>
    </
    OBJECT
    When test on the server that has the SWF everything works fine. All my scripts run as well as my connections to the remote mysql server.

    When the SWF is run from the Remote server, it doesnt run the php scripts.

    I thought that if the SWF and the scripts were on the same server, it would run fine.

    Instead I get a Error #2048: Security sandbox violation cannot load data from getCourses.php.

    Please Help.

    I have 100% access to the webserver the the SWF and scripts are not saved on.

  8. #8
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Relative urls are interpreted as relative to the page which embeds the swf rather than relative to the swf.

    What it comes down to is that you need a crossdomain.xml file on the server with the resource you are trying to access from the swf. That file should allow access from the other server.

  9. #9
    Member
    Join Date
    Apr 2007
    Posts
    93
    Just to clarify:

    Server 1:
    aspx page Embeds SWF

    Server 2:
    SWF file
    PHP Scripts
    crossdowmain.xml

    Is that correct? Or does the cross domain go on Server 1? And if so what directory?

  10. #10
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You're correct in that the crossdomain.xml has to go on server 2 if the resources you're trying to access (the php urls) are on server 2. I hope you actually named the file correctly.

    I'm not 100% sure that you should need a crossdomain.xml in that situation since the SWF is on the same server as the PHP, but as I put above, the relative urls are probably resolved relative to the embedding file on server 1. Also, be sure that the domain names are EXACTLY correct. www.server2.com is NOT the same as server2.com, and will cause possible crossdomain issues if you are not careful.

  11. #11
    Member
    Join Date
    Apr 2007
    Posts
    93
    So frustrated and at a complete loss.
    I tried puting this file on both servers:
    PHP Code:
    <?xml version="1.0"?>
    <!-- http://www.zetapsioshawa.org/crossdomain.xml -->
    <cross-domain-policy>
      <allow-access-from domain="*" secure=false/>
    </cross-domain-policy>
    And manually trying to load them with:
    flash.system.Security.loadPolicyFile("www.zetapsio shawa.org/crossdomain.xml") And I put on on the other server and tried loading that one. Still nothing works. I wish I could just hit the damn easy button on this one. It doesnt seem like it should be this difficult.

  12. #12
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    It really shouldn't be as difficult as it is. The file you've got there is as lenient as can be.
    Can you copy and paste the exact error message you're getting, with only the actual domain censored if necessary?

  13. #13
    Member
    Join Date
    Apr 2007
    Posts
    93
    Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://www********.org/handicap/fina...econ31@aol.com cannot load data from getCourses.php.
    at handicapV2_fla::MainTimeline/loadCourseXMLData()
    at handicapV2_fla::MainTimeline/loaderComplete()

  14. #14
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Well, that's odd, usually the error indicates the server of the remote resource.

    Is the url to getCourses.php "http://www*******.org/handicap/final/getCourses.php" ?

    What url are you using in the URLRequest?

  15. #15
    Member
    Join Date
    Apr 2007
    Posts
    93
    OMG!!! I owe you beer. Your URLRequest question made me think to use absolute paths instead of "getCourses.php" AND ITS WOKRING!!! I am seriously goin on vacation now.
    My next post is from Dominican Republic!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center