/** * @param $url * @param string $data * @param array $headers * @return bool|array|mixed|\SimpleXMLElement */ protected function processCurl($url, $data = "", $headers = []) { $success = false; $errors = []; $result = parent::processCurl($url, $data, $headers); if ($result) { $resultObj = simplexml_load_string($result); if ($resultObj->fault) { foreach ($resultObj->fault as $error) { $errors[] = (string) $error['string']; } } else { $success = true; } } return ['success' => $success, 'errors' => $errors, 'data' => $result, 'obj' => $resultObj ? $resultObj : false]; }
/** * @param $url * @param string $data * @param array $headers * @return bool|array|mixed|\SimpleXMLElement */ protected function processCurl($url, $data = "", $headers = []) { $success = false; $errors = []; $result = parent::processCurl($url, $data, $headers); if ($result) { $resultObj = simplexml_load_string($result); if ($resultObj->Error) { foreach ($resultObj->Error as $error) { $errors[] = (string) $error; } } elseif ($this->returnWarnings && $resultObj->Success && $resultObj->Success->Warning) { foreach ($resultObj->Success->Warning as $warning) { $errors[] = 'Warning: ' . (string) $warning; } } else { $success = true; } } return ['success' => $success, 'errors' => $errors, 'data' => $result, 'obj' => $resultObj ? $resultObj : false]; }
function getRadio($date) { global $refresh; $strDate = gmdate('Y-m-d', $date); $gosfile = './gos/' . $strDate; $gosjson = null; if (!file_exists($gosfile) or $refresh) { $gosjson["title"] = "每日福音"; $gosjson["date"] = $strDate; $gosjson["logo"] = "http://www.cathassist.org/radio/logos/gos.jpg"; $gosjson["desc"] = "一起聆听主的教诲"; $itemsrc = "http://media.cathassist.org/thought/mp3/" . $strDate . ".mp3"; if (url_exists($itemsrc)) { $title = "每日福音"; $gosjson['items'][0] = array('title' => $title, 'src' => $itemsrc); file_put_contents($gosfile, json_encode($gosjson)); BaseChannel::append2All("gos", $gosjson); } else { return null; } } else { $gosjson = json_decode(file_get_contents($gosfile), true); } return $gosjson; }