/**
  * 同步头像到指定的UC uid(同步到UC)。
  * 适用于已经安装了UC(不排除部分站长将旧版本DZ自行修改加载了UC)、或者是DZ 6.1及以上版本(也会安装了UC)
  *
  * @param integer $uid DZ uid
  * @return integer 同步结果。正常为0,否则:
  *  -1到-10:此错误码预留给_getFaceAndCreateTemp方法,请自行参阅该方法的注释
  * 
  * 	-10:本地编码失败(一般是无法生成3种头像文件所致)
  * 	-11:与UC进行HTTP通讯出错
  * 	-12:UC返回头像编码解码失败代码
  * 	-13:UC返回头像上传失败代码
  * 	-14:UC返回找寻传参uid失败代码
  * 	-15:UC返回未知错误代码
  */
 function syncToUC($uid)
 {
     $step1result = $this->_getFaceAndCreateTemp($uid);
     if ($step1result < 0) {
         return $step1result;
     }
     $postdata = $this->_createUCAvatarPostdata();
     if (count($postdata) != 3) {
         return -10;
     }
     $this->http->setUrl($this->_createUCUrl());
     $this->http->setData($postdata);
     $this->_delTempFace();
     //构造完UC所需数据后,就可以删除临时文件了。
     $response = $this->http->request('post');
     $code = (int) $this->http->getState();
     if (defined('XWB_DEV_LOG_ALL_RESPOND') && XWB_DEV_LOG_ALL_RESPOND == true) {
         XWB_plugin::LOG("[FACE SYNC RESULT]\t" . $this->_createUCUrl() . "\t{$code}\t" . htmlspecialchars($response));
     }
     if (200 !== $code) {
         return -11;
     }
     if (preg_match('/type="error"[ ]+value="([\\-\\+0-9]+)"/', $response, $matchErr)) {
         $matchErr = isset($matchErr[1]) ? (int) $matchErr[1] : -99;
         switch ($matchErr) {
             case '-1':
                 return -14;
             case '-2':
                 return -12;
             default:
                 return -15;
         }
     }
     $match = array();
     if (!preg_match('/success="([0-9]+)"/', $response, $match)) {
         return -15;
     }
     if (!isset($match[1]) || (int) $match[1] != 1) {
         return -13;
     } else {
         return 0;
     }
 }