" . "\n";
$result .= "
".htmlentities($xml).""); exit("
".htmlentities($result).""); // exit($result); return $result; } /** * Updates an existing recipe by performing an HTTP PUT * on its feed URI, using the updated values a PUT data. */ function updateItem() { $ch = curl_init(); /* Create a CURL handle. */ global $developerKey; /* Prepare the data for HTTP PUT. */ $putString = buildInsertXML(); $putData = tmpfile(); // exit("=======>
".var_dump($putData).""); fwrite($putData, $putString); fseek($putData, 0); /* Set cURL options. */ curl_setopt($ch, CURLOPT_URL, $_POST['link']); curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_INFILE, $putData); curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: AuthSub token="' . $_POST['token'] . '"', 'X-Google-Key: key=' . $developerKey, 'Content-Type: application/atom+xml')); $result = curl_exec($ch); /* Execute the HTTP request. */ fclose($putData); /* Close and delete the temp file. */ curl_close($ch); /* Close the cURL handle. */ return $result; } /** * Deletes a recipe by performing an HTTP DELETE (a custom * cURL request) on its feed URI. */ function deleteItem() { $ch = curl_init(); global $developerKey; /* Set cURL options. */ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($ch, CURLOPT_URL, $_POST['link']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: AuthSub token="' . $_POST['token'] . '"', 'X-Google-Key: key=' . $developerKey)); $result = curl_exec($ch); /* Execute the HTTP request. */ curl_close($ch); /* Close the cURL handle. */ return $result; } /** * Deletes all recipes by performing an HTTP POST to the * batch URI. */ function batchDelete() { $ch = curl_init(); /* Create a CURL handle. */ global $developerKey, $itemsFeedURL; /* Set cURL options. */ curl_setopt($ch, CURLOPT_URL, $itemsFeedURL . "/batch"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: AuthSub token="' . $_POST['token'] . '"', 'X-Google-Key: key=' . $developerKey, 'Content-Type: application/atom+xml')); curl_setopt($ch, CURLOPT_POSTFIELDS, buildBatchXML()); $result = curl_exec($ch); /* Execute the HTTP request. */ curl_close($ch); /* Close the cURL handle. */ return $result; } /** * Callback function for XML start tags parsed by * xml_parse. */ function startElement($parser, $name, $attrs) { global $curElement, $foundEntry, $parsedEntries; $curElement = $name; if($curElement == "ENTRY") { $foundEntry = true; $parsedEntries[count($parsedEntries)] = array(); } else if($foundEntry && $curElement == "LINK") { $parsedEntries[count($parsedEntries) - 1][$attrs["REL"]] = $attrs["HREF"]; } } /** * Callback function for XML end tags parsed by * xml_parse. */ function endElement($parser, $name) { global $curElement, $foundEntry, $parsedEntries; if($name == "ENTRY") { $foundEntry = false; } } /** * Callback function for XML character data parsed by * xml_parse. */ function characterData($parser, $data) { global $curElement, $foundEntry, $parsedEntries; if($foundEntry) { $parsedEntries[count($parsedEntries) - 1][strtolower($curElement)] = $data; } }