Flex: testing/running php proxy locally

When accessing URL’s through HttpServices from a remote domain, it often works fine on the local system but fails to connect when the swf is uploaded to the web (google searh ‘flex crossdomain.xml proxy’).

A common way around this is to place a PHP file on your web server that acts as a go-between for the remote site and the swf (an example discussed on Dennis Jaamaan’s site, with proxy code).

This article explains how to setup a local PHP server, and test your PHP proxy locally through Flex Builder 3

1. Download a PHP server: http://www.wampserver.com/en/download.php

2. Install it, leaving whatever default settings it suggests.

3. Click the WampServer taskbar icon, and go to PHP/PHP_extensions/ and click php_curl (need to enable this to use the example below). Then click Start All Services & Put Online.

4. Create a php file named flexProxy.php and put in the code below:

<?php
$ch = curl_init();
$timeout = 30;
$userAgent = $_SERVER['HTTP_USER_AGENT'];

$url = $_REQUEST['url'];
$place = $_REQUEST['place'];

$fullGoogleWeatherPath = $url . $place;

curl_setopt($ch, CURLOPT_URL,$fullGoogleWeatherPath);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo curl_error($ch);
} else {
    curl_close($ch);
    echo $response;
}
?>

5. Save this file and put it in the localhost directory: C:\wamp\www\

6. Now for the Flex part. In a new project, create a webservice like the following one:

<mx:HTTPService url="http://localhost/flexProxy.php?"
 	id="googleWeatherService"
 	method="POST" showBusyCursor="true" resultFormat="e4x"
 	fault="serviceFault(event)" result="googleResult(event)">
 	<mx:request xmlns="">
 		<url>http://www.google.com/ig/api?weather=</url>
 		<place>
 			{googleRequestString}
 		</place>
 	</mx:request>
</mx:HTTPService>

<mx:TextArea x="459" y="133" width="419" height="297"
         id="googleResultTextArea"
         text="{googleWeatherService.lastResult.weather}" />

7. Somewhere in you code set the googleRequestString and call the web service:

googleRequestString = “Dublin,Ireland”;
googleWeatherService.send();

This should then populate the textArea as its text is bound to the lastResult. Nice one.

8. When you want to load your code to the web, change the following bit of code:
<mx:HTTPService url=”http://localhost/flexProxy.php?&#8221;
to
<mx:HTTPService url=”assets/flexProxy.php”

and make sure that you have included an ‘assets’ forder in your source with ‘flexProxy.php’ inside it.

9. In Flex Builder 3 go to Projects, Export release build, and copy all the files/folders in the release-build folder to your web server.

10. Bada bing, you’ve got google weather data (how do these thing always work out to 10 steps?)

Update: to test for errors/conflicts directly put the following in your browser:
http://localhost/flexProxy.php?url=http://www.google.com/ig/api?weather=&place=Dublin,Ireland
You wont see the xml response, but you should get no errors.

Use http://www.google.com/ig/api?weather=Dublin,Ireland to see the xml.

Advertisements

Tags: , , , , , ,

76 Responses to “Flex: testing/running php proxy locally”

  1. Bhavesh Dave Says:

    Dear Sir

    thank very much. your blog is very useful to me. It is ultimate.
    I have solve many problems of VISUAL STUDIO 2008 deployment related.

    Thank you again,

  2. Cathi Hochberg Says:

    Hello,guy!I like this article,your blog is great!

  3. frenky Says:

    LnJ2uZ http://gdjI3b7VaWpU1m0dGpvjRrcu9Fk.com

  4. Hfuqeglq Says:

    One moment, please photos cute preteens 371

  5. Rnarrbrv Says:

    I’m from England young teen sexx 28651

  6. Mofccvdy Says:

    Recorded Delivery Pics Of Teenies Bbs
    =-PP

  7. URL Says:

    The total glance of your site is great, let smartly as the content! 969429

    • Florence Says:

      My favorite bird Martina )Two wonderful captures of itw382#0;.&ow i loved to go out for the birds but i don’t have the time at the moment ;( But i’m enjoying your photo’s right now ;-D

  8. upcoming movie trailers Says:

    Some genuinely good and utilitarian information on this web site, as properly I believe the style has got excellent capabilities. 106945

  9. Houses for rent Raleigh NC Says:

    What others have stated and in some uncommon cases, suicide may occur. 260870

  10. Foerdertechnik Says:

    I conceive this internet web site has got some really superb information for everybody : D. 797850

  11. Specials Says:

    I undoubtedly didnt recognize that. Learnt some thing new nowadays! Thanks for that. 89974

  12. tulum Says:

    I must test with you here. Which is not one thing I normally do! I enjoy studying a submit that will make people think. Also, thanks for allowing me to comment! 816144

  13. blouson cuir femme Says:

    I see something actually fascinating about your internet web site so I saved to bookmarks . 113309

  14. pret personnel en ligne Says:

    Yay google is my king helped me to locate this outstanding web site! . 975051

  15. Tarzan vibrator Says:

    The digital cigarette makes use of a battery and a small heating element the vaporize the e-liquid. This vapor can then be inhaled and exhaled 715749

  16. ייעוץ עסקי Says:

    Merely wanna state that this really is really beneficial , Thanks for taking your time to write this. 610969

  17. quit smoking Says:

    I like your writing style truly loving this internet site . 59699

  18. resultat du quinte Says:

    superb post. Neer knew this, appreciate it for letting me know. 954291

  19. (iPhone 5 Says:

    Intriguing post. Positive that Ill come back here. Good function. 977934

  20. atlas userpage Says:

    Delighted for you to discovered this site write-up, My group is shopping a lot more often than not regarding this. This can be at this moment undoubtedly what I are already seeking and I own book-marked this specific site online far too, Ill often be maintain returning soon enough to appear at on your special weblog post. 802100

  21. νυφικο μακιγιαζ Says:

    There is noticeably lots of cash to comprehend about this. I assume youve created certain nice points in functions also. 853350

  22. παραδοσιακες στολες Says:

    I respect your piece of function, appreciate it for all of the intriguing content material . 604661

  23. newcastle bodybuilding Says:

    You must participate in a contest for among the best blogs on the web. I will suggest this web site! 534922

  24. Nikon D4 review Says:

    Great post, Im looking forward to hear more from you!! 496353

    • Justice Says:

      Qué excelente idea, amiga! me encantan las manzanas asadas…en casa las comemos muy a menudo pero nunca se me habría ocurrido prepararlas &q&!s;abrigaditatuquot;o!! exquisitas!!!!!!!!!!!!!

  25. φωτοβολταϊκά συστήματα Says:

    What a lovely weblog. Ill surely be back once again. Please preserve writing! 105279

  26. URL Says:

    Very informative post. Your current Website style is awesome as well! 920841

  27. Read More Here Says:

    Excellent humans speeches and toasts, possibly toasts. are hands down transferred at some time by means of party and expected to turn into really funny, amusing not to mention educational inside the mean time. finest man wedding speeches 879367

  28. Viagra Says:

    Thanks for the info provided! I was researching for this write-up for a long time, but I was not able to see a dependable source. 847768

  29. Citalopram reviews Says:

    Thankyou for all your efforts which you have put in this. really fascinating information . 787096

  30. How to wear combat boots Says:

    I adore your wp style, wherever did you download it by means of? 168923

  31. φοιτητικες εργασιες Says:

    As soon as I found this internet site I went on reddit to share some of the love with them. 223318

  32. Debbie Majerowski Says:

    Really superb details can be located on weblog . 270463

  33. windows free hd wallpapers Says:

    You got a really superb site, Glad I noticed it by means of yahoo. 605325

  34. ancient china Says:

    Wonderful post, thank you so considerably for sharing. Do you happen to have an RSS feed I can subscribe to? 980402

  35. vaginal tightening Says:

    Quite very good written post. It is going to be valuable to anybody who usess it, including myself. Maintain up the very good function – canr wait to read far more posts. 580612

  36. home evaluation Says:

    Definitely composed content material material , thankyou for data . 530692

  37. blazer femme Says:

    I actually like your writing style, excellent information , thankyou for putting up : D. 751651

  38. kiirlaen Says:

    Yay google is my king assisted me to find this outstanding site! . 300790

    • Moon Says:

      ya ke terubah tu amat bendar bajik bala sekeda deka mai aram beekgala..nlrap ke kita ila enda sumbung enti nyema bisi orang talipaun suh kita..anang enggai bejaku au wai..nya aja ari aku..hehehe

  39. china mould Says:

    Nice site, nice and easy on the eyes and great content too. Do you need many drafts to make a post? 377117

  40. condominium in singapore Says:

    Good post, well put together. Thanks. I will be back soon to check out for updates. Cheers 218653

  41. wood plantation shutters Says:

    Have read a couple of of the articles on your web site now, and I truly like your style of blogging. I added it to my favorites weblog site list and will probably be checking back soon. 13000

  42. SEO Newcastle Australia Says:

    youve got an crucial weblog proper here! would you wish to make some invite posts on my weblog? 403984

  43. icebreaker bingo Says:

    Awesome weblog, Im going to spend a lot more time researching this subject 641495

  44. เพลงใหม่ล่าสุด อาร์สยาม Says:

    I like this internet web site its a master peace ! Glad I detected this on google . 877927

  45. dog grooming tables Says:

    A thoughtful opinion and ideas Ill use on my internet page. Youve certainly spent some time on this. Properly carried out! 454194

  46. http://smedio.com#digital marketing Says:

    I like this site so much, saved to favorites . 911431

  47. computer repair Says:

    Lots of writers recommend just writing and composing no matter how bad and if the story is going to develop, youll suddenly hit the zone and itll develop. 885019

  48. homes for sale kennewick wa Says:

    In todays news reporting clever journalists function their very own slant into a story. Bloggers use it promote their works and a lot of just use it for enjoyable or to stay in touch with pals far away. 435490

    • Constance Says:

      This is so vintage and pretty. Nice colours on the background too. So pleased your enjoying our chlseangel, thanks for your continued support at Make My Monday. Caz

  49. shipping to usa Says:

    Ive just been talking to Sean Gallagher about his upcoming Instant Income Cash Machine course, and hes been kind enough to fill me in on a couple of details regarding his upcoming course. 799029

  50. R4 Kaart Says:

    I really like your writing style, good information, appreciate it for posting : D. 785914

  51. GPS Says:

    More than and more than once again I like to take into consideration this troubles. As a matter of fact it wasnt even a month ago that I thought about this quite thing. To be honest, what could be the answer though? 462607

  52. Relocating to Phoenix Says:

    Wow, awesome blog structure! How long have you been running a blog for? you made blogging look easy. The total look of your site is wonderful, let alone the content material! 524325

  53. hechizos Says:

    I was looking for this. Really refreshing take on the information. Thanks a lot. 290450

  54. google Says:

    Hi this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. Im starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be greatly appreciated! 829670

  55. Bludomain Alternative Says:

    if this post was likened to a flavor of yogurt, what flavor would it be? Banana, I think. 822292

  56. fewStones Says:

    Hi this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML. Im starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be greatly appreciated! 411276

  57. http://www.ergonomicchair.net#Office chair Says:

    for however one more wonderful informative post, Im a loyal reader to this weblog and I cant stress enough how considerably valuable data Ive learned from reading your content material. I genuinely appreciate all of the hard function you put into this wonderful weblog. 461830

  58. one x Says:

    This will be a terrific blog, would you be interested in doing an interview about just how you developed it? If so e-mail me! 910718

  59. uk slots online Says:

    Giving you the most effective News is really significantly imptortant to us. 218320

  60. car insurance Says:

    I like this web site very much, Its a really nice post to read and get info . 458149

  61. dailies blog Says:

    This internet website is my aspiration, extremely outstanding design and Perfect articles. 183527

  62. jailbreak iphone 4s mac Says:

    A blog like yours should be earning much money from adsense..-., 181298

  63. listasal mensajitos gratis facebook Says:

    Id forever want to be update on new posts on this site , bookmarked ! . 745648

  64. home based business, business opportunities, mlm, network marketing, medical, dental, ghcnow, travel, healthcare, work Says:

    I will tell your buddies to go to this website. .Thanks for the write-up. 134670

  65. Iflyooua Says:

    What are the hours of work? http://naehegija.de.tl ls nonude models Could anything be better than having an entire team fuck you outdoors? This girl is living my dream…to be naked and esposed gangbanged outdoors and in public by a huge gang of men…anyone who happened by could see them all plunging their cocks into me and see how I was loving each stroke of those dicks as they rammed into me again and again!

  66. Bsulexaa Says:

    An estate agents http://usifupurasepi.de.tl tit little pussy She’s cute and looks like she enjoyed it but i don’t know if i could rub dicks with another man even to make her happy.

  67. click here Says:

    How do you make a blog site look this good!? Email me if you want and share your wisdom. Id be appreciative!

  68. znovu naplněné inkoustové cartridges HP 920 Says:

    A five-page words in addition to color selection graphics impress basically brought A couple of.
    23ppm, however, not just 50 % your posted number.
    Photos patterns originated by means of somewhat swiftly,
    with a Fifteen y 10cm shoot with high-quality choosing One particular:Thirty-four and then a comparable photograph, with natural top
    quality originating from a PictBridge digicam, required fairly zippy
    Fifty-seven moments. tonery samsung scx-3405fw cartridge point todmorden walmart ink cartridges hp 564
    Moen Výměna cartridges cartridge comparison
    guide 2 měnící se inkoustová cartridge HP Deskjet 1050 tonery SAMSUNG ML-2510 cartridge
    bottom bracket removal.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: