diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2012-08-08 16:41:21 -0400 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2012-08-08 16:41:21 -0400 |
commit | 90e49e0b5ffb2e378fb9c959c17f88160a8ebeb3 (patch) | |
tree | 04bcec45847a4c7561d20df20def457cede05b0f /ajax | |
parent | 8dc1c6c6ea83f4ffe5fc0c290e317cd9bacb6d6f (diff) |
curl connections between importopml and createfeed
Diffstat (limited to 'ajax')
-rw-r--r-- | ajax/.importopml.php.kate-swp | bin | 0 -> 150 bytes | |||
-rw-r--r-- | ajax/importopml.php | 33 |
2 files changed, 33 insertions, 0 deletions
diff --git a/ajax/.importopml.php.kate-swp b/ajax/.importopml.php.kate-swp Binary files differnew file mode 100644 index 000000000..9447b6429 --- /dev/null +++ b/ajax/.importopml.php.kate-swp diff --git a/ajax/importopml.php b/ajax/importopml.php index c2230c8b8..3aaccd840 100644 --- a/ajax/importopml.php +++ b/ajax/importopml.php @@ -41,5 +41,38 @@ if ($parsed == null) { bailOut($l->t('An error occurred while parsing the file.')); } +// $ch is the handler for the curl connection +function addFeed($feedurl, $folderid, $ch) { + + $data = array('feedurl' => $feedurl, 'folderid' => $folderid); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + $result = curl_exec($ch); + + if($result === false) { + bailOut(curl_error($ch)); + } else { + bailOut($result); + } +} + +$data = $parsed->getData(); +$url = OCP\Util::linkToAbsolute('news', 'ajax/createfeed.php'); +$ch = curl_init($url); +curl_setopt($ch, CURLOPT_POST, TRUE); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + +foreach($data as $collection) { + if ($collection instanceOf OC_News_Feed) { + $feedurl = $collection->getUrl(); + $folderid = 0; + addFeed($feedurl, $folderid, $ch); + } +} + +addFeed(null, null, $ch); +$result = curl_exec($ch); + +curl_close($ch); + OCP\JSON::success(array('data' => array('title'=>$parsed->getTitle(), 'count'=>$parsed->getCount()))); |