How to enable curl_init() in PHP Runtime?

651 views
Skip to first unread message

Kseniya Andryushyna

unread,
Sep 21, 2014, 12:26:03 AM9/21/14
to google-a...@googlegroups.com
Hi,
I'm pretty new to programing all together and PHP in particular, so I apologize if my question sound stupid.

I want to write an app that will use Maps Engine API. I've installed Apps Engine PHP SDK, gone through all registrations and so on.
The 1st example shown in Map Engine page is not running in PHP Runtime. I receive an error: Call to undefined function curl_init(). From bits of information that I found and understood it looks like cURL library is not installed.
Could you please help me to understand if my assumption is true and if it is - advise how to install the library?

Thanks

Barry Hunter

unread,
Sep 22, 2014, 11:13:36 AM9/22/14
to google-appengine
Curl is library that for making HTTP requests. 

AppEngine has a different library - URL Fetch - which has been intergrated into the standard PHP wrappers. 

The code should be converted to use standard php functions instead. 

See:

The function GetAsJson could be rewritten as something like

 function GetAsJson($url) {
   
$data = file_get_contents($url);
    foreach ($http_response_header as $header_line)
if (preg_match('/^HTTP\/\d.\d (\d+)/,$header_line,$match))
$http_status = intval($match[1]);
 
   
return array($http_status, json_decode($data));
}
getting the data itself is as simple as using file_get_contents, but getting the status code is a little more tricky. 

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Vinny P

unread,
Sep 23, 2014, 12:22:15 AM9/23/14
to google-a...@googlegroups.com
I would suggest using pUrl: https://github.com/azayarni/purl 

It's basically a reimplementation of curl in pure PHP. It doesn't support all of curl's features, but it'll get you up and running quickly and you can fix any problems down the road.

In the longer run, you should star the following issue: https://code.google.com/p/googleappengine/issues/detail?id=9343 ( PHP - cUrl library) for curl support on App Engine.

 
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Reply all
Reply to author
Forward
0 new messages