- $context = stream_context_create(array('http' => array('method' => "POST",
- 'header' =>
- "Content-Type: text/xml\r\n".
- "User-Agent: Laconica/".LACONICA_VERSION."\r\n",
- 'content' => $request)));
- $file = file_get_contents($notify_url, false, $context);
- $response = xmlrpc_decode($file);
- if (xmlrpc_is_fault($response)) {
+ $request = HTTPClient::start();
+ $request->setConfig('connect_timeout', common_config('ping', 'timeout'));
+ $request->setConfig('timeout', common_config('ping', 'timeout'));
+ try {
+ $httpResponse = $request->post($notify_url, array('Content-Type: text/xml'), $req);
+ } catch (Exception $e) {
+ common_log(LOG_ERR,
+ "Exception pinging $notify_url: " . $e->getMessage());
+ continue;
+ }
+
+ if (!$httpResponse || mb_strlen($httpResponse->getBody()) == 0) {
+ common_log(LOG_WARNING,
+ "XML-RPC empty results for ping ($notify_url, $notice->id) ");
+ continue;
+ }
+
+ $response = xmlrpc_decode($httpResponse->getBody());
+
+ if (is_array($response) && xmlrpc_is_fault($response)) {