I have a code written in PHP and currently running on my shared hosting. Now I'm going to move it on Google App Engine.
sendRequest()
method sends post data and cookies to another website and returns a response.
private function sendRequest($url, array $data = array()) {
$ch = curl_init(self::URL_BASE);
$curlConfig = array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_COOKIE => "user_name=" . $this->username . "; user_password=" . md5($this->password));
if ($url == self::URL_LOGIN) {
$this->cookieFile = tempnam("/tmp", "CURLCOOKIE");
$curlConfig[CURLOPT_COOKIEJAR] = $this->cookieFile;
} else {
$curlConfig[CURLOPT_COOKIEFILE] = $this->cookieFile;
}
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
Problems:
- CURL module is not supported in App Engine
-
tempnam()
function is disabled
I've searched a lot, but couldn't find any alternatives. fsockopen()
is also disabled.