コード例 #1
0
ファイル: sender.php プロジェクト: jmangarret/webtuagencia24
 /**
  * Send xml data to
  * @param string $remote_url
  * @param string $xml
  * @param string $username
  * @param string $password
  * @param int $debug when 1 (or 2) will enable debugging of the underlying xmlrpc call (defaults to 0)
  * @return xmlrpcresp obj instance
  */
 private static function _xmlrpc_j2xml_send($remote_url, $xml, $username, $password, $debug = 0)
 {
     $protocol = '';
     $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
     $client = new xmlrpc_client($remote_url);
     $client->return_type = 'xmlrpcvals';
     $client->request_charset_encoding = 'UTF-8';
     $client->user_agent = J2XMLVersion::$PRODUCT . ' ' . J2XMLVersion::getFullVersion();
     $client->setDebug($debug);
     $msg = new xmlrpcmsg('j2xml.import');
     $p1 = new xmlrpcval(base64_encode($xml), 'base64');
     $msg->addparam($p1);
     $p2 = new xmlrpcval($username, 'string');
     $msg->addparam($p2);
     $p3 = new xmlrpcval($password, 'string');
     $msg->addparam($p3);
     $res = $client->send($msg, 0);
     if (!$res->faultcode()) {
         return $res;
     }
     if ($res->faultString() == "Didn't receive 200 OK from remote server. (HTTP/1.1 301 Foun)") {
         $res = $client->send($msg, 0, $protocol = 'http11');
         if (!$res->faultcode()) {
             return $res;
         }
     }
     if ($res->faultString() == "Didn't receive 200 OK from remote server. (HTTP/1.1 303 See other)") {
         $headers = http_parse_headers($res->raw_data);
         $client = new xmlrpc_client($headers['Location']);
         $client->return_type = 'xmlrpcvals';
         $client->request_charset_encoding = 'UTF-8';
         $client->user_agent = J2XMLVersion::$PRODUCT . ' ' . J2XMLVersion::getFullVersion();
         $client->setDebug($debug);
         $res = $client->send($msg, 0, $protocol);
     }
     return $res;
 }