thieumao

xxxtest.php 2

Feb 7th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.04 KB | None | 0 0
  1. <?php
  2. // Truyen tham so vao  
  3. $title = "Bong da";
  4. $body = "Noi dung bong da";
  5. $category = "";
  6. $introtext = "Gioi thieu tran dau";
  7. $imageFull = "http://img.tamtay.vn/files/photo2/2010/12/9/13/675319/4d0077c4_521c4544_1291831790-bong-da-vn39.jpg";
  8. //$thumbnail = $imageFull;
  9. $linksource = "link nguon";
  10. $linkserver = "link server";
  11. $linkyoutube= "link youtube";
  12. $linkdropbox = "link dropbox";
  13. $matchtime = "02/05/2014";
  14. $ishot = "";
  15.  
  16.  
  17. // Tai anh tu noi khac ve server
  18. include('xxxxClassDownload.php');
  19. $linkanhgoc = $imageFull;
  20. $down = new xxxxClassDownload($linkanhgoc);
  21. echo "<br> Link goc: " . $linkanhgoc;
  22. echo "<br> Link anh da up: " . $down->getLinkanhdaup();
  23. echo "<br>__________________<br>";
  24.  
  25. // copy vao wordpress
  26. echo "<br>Service tra ve cua IXR_Library.php<br>";
  27. include('IXR_Library.php');
  28. $myFile = $down->getLinkanhdaup();
  29. $fh = fopen($myFile, 'r');
  30. $fs = filesize($myFile);
  31. $theData = fread($fh, $fs);
  32. fclose($fh);
  33.  
  34. $usr = 'thieumao';
  35. $pwd = '12345678a@';
  36. $xmlrpc = 'http://9football.net/xmlrpc.php';
  37. $client = new IXR_Client($xmlrpc);
  38.  
  39. $client->debug = true;
  40. $params = array('name' => 'bongda.jpg', 'type' => 'image/jpg', 'bits' => new IXR_Base64($theData), 'overwrite' => false);
  41. $res = $client->query('wp.uploadFile',1, $usr, $pwd, $params);
  42.  
  43. echo "<br> Lay thu: <br>";
  44.  
  45. $a = $client->message->params[0];;
  46. print_r ($a);
  47. echo "<br>";
  48. echo "<br>ID wordpress: " . $a[id];
  49. echo "<br>URL wordpress: " . $a[url];
  50. echo "<br>__________________<br>";
  51. $idhinhanh = $a[id];
  52. $urlhinhanh = $a[url];
  53.  
  54. // up bai viet thu
  55. class XMLRPClientWordPress
  56. {
  57.     /*
  58.     var $XMLRPCURL = "http://9football.net/xmlrpc.php";
  59.     var $UserName  = "admin";
  60.     var $PassWord = "123456789a@";
  61.     */
  62.  
  63.     var $XMLRPCURL;
  64.     var $UserName;
  65.     var $PassWord;
  66.  
  67.     // constructor
  68.     public function __construct($xmlrpcurl, $username, $password)
  69.     {
  70.         $this->XMLRPCURL = $xmlrpcurl;
  71.         $this->UserName  = $username;
  72.         $this->PassWord = $password;
  73.            
  74.     }
  75.  
  76.     function send_request($requestname, $params)
  77.     {
  78.         $request = xmlrpc_encode_request($requestname, $params);
  79.         $ch = curl_init();
  80.         curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  81.         curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);
  82.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  83.         curl_setopt($ch, CURLOPT_TIMEOUT, 1);
  84.         $results = curl_exec($ch);
  85.         curl_close($ch);
  86.         return $results;
  87.     }
  88.  
  89.     function create_post($title,$body,$category,$keywords='',$encoding='UTF-8')
  90.     {
  91.         $title = htmlentities($title,ENT_NOQUOTES,$encoding);
  92.         $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
  93.  
  94.         $content = array(
  95.             'title'=>$title,
  96.             'description'=>$body,
  97.             'mt_allow_comments'=>0,  // 1 to allow comments
  98.             'mt_allow_pings'=>0,  // 1 to allow trackbacks
  99.             'post_type'=>'post',
  100.             'mt_keywords'=>$keywords,
  101.         /*
  102.             "custom_fields" => array(
  103.         array( 'key' => 'linksource', 'value' => 'linksource ngay valentin' ),
  104.         array( 'key' => '_linksource', 'value' => 'field_52f1e88803f57'),
  105.         array( 'key' => 'matchtime', 'value' => '14/02/2014' ),
  106.         array( 'key' => '_matchtime', 'value' => 'field_52f1e88805c33')
  107.         ),
  108.         */
  109.  
  110.             'categories'=>array($category)
  111.         );
  112.         $params = array(0,$this->UserName,$this->PassWord,$content,true);
  113.  
  114.         return $this->send_request('metaWeblog.newPost',$params);
  115.  
  116.     }
  117.  
  118.     function create_post_football($title,$body,$category,$introtext,$imageFull,$thumbnail,$linksource,
  119.     $linkserver,$linkyoutube,$linkdropbox,$matchtime,$ishot,$keywords='',$encoding='UTF-8')
  120.     {
  121.         $title = htmlentities($title,ENT_NOQUOTES,$encoding);
  122.         $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
  123.         $content = array(
  124.             'title'=>$title,
  125.             'description'=>$body,
  126.             'mt_allow_comments'=>1,  // 1 to allow comments
  127.             'mt_allow_pings'=>1,  // 1 to allow trackbacks
  128.             'post_type'=>'post',
  129.             'mt_keywords'=>$keywords,
  130.             "custom_fields" => array(
  131.                 array( 'key' => 'introtext', 'value' => $introtext ),
  132.                 array( 'key' => '_introtext', 'value' => 'field_52f1e887ee97f'),
  133.                 array( 'key' => 'imageFull', 'value' => $imageFull ),
  134.                 array( 'key' => '_imageFull', 'value' => 'field_52f1e887ef089'),
  135.                 array( 'key' => 'thumbnail', 'value' => $thumbnail ),
  136.                 array( 'key' => '_thumbnail', 'value' => 'field_52f1e887ef759'),
  137.                 array( 'key' => 'linksource', 'value' => $linksource ),
  138.                 array( 'key' => '_linksource', 'value' => 'field_52f1e88803f57'),
  139.                 array( 'key' => 'linkserver', 'value' => $linkserver ),
  140.                 array( 'key' => '_linkserver', 'value' => 'field_52f1e88804684'),
  141.                 array( 'key' => 'linkyoutube', 'value' => $linkyoutube ),
  142.                 array( 'key' => '_linkyoutube', 'value' => 'field_52f1e88804d93'),
  143.                 array( 'key' => 'linkdropbox', 'value' => $linkdropbox ),
  144.                 array( 'key' => '_linkdropbox', 'value' => 'field_52f1e888054e4'),
  145.                 array( 'key' => 'matchtime', 'value' => $matchtime ),
  146.                 array( 'key' => '_matchtime', 'value' => 'field_52f1e88805c33'),
  147.                 array( 'key' => 'ishot', 'value' => $ishot ),
  148.                 array( 'key' => '_ishot', 'value' => 'field_52f1e888063a4'),
  149.             ),
  150.             'categories'=>array($category)
  151.         );
  152.         $params = array(0,$this->UserName,$this->PassWord,$content,true);
  153.         return $this->send_request('metaWeblog.newPost',$params);
  154.  
  155.     }
  156.  
  157.     function create_page($title,$body,$encoding='UTF-8')
  158.     {
  159.         $title = htmlentities($title,ENT_NOQUOTES,$encoding);
  160.  
  161.         $content = array(
  162.             'title'=>$title,
  163.             'description'=>$body
  164.         );
  165.         $params = array(0,$this->UserName,$this->PassWord,$content,true);
  166.  
  167.         return $this->send_request('wp.newPage',$params);
  168.     }
  169.  
  170.     function display_authors()
  171.     {
  172.         $params = array(0,$this->UserName,$this->PassWord);
  173.         return $this->send_request('wp.getAuthors',$params);
  174.     }
  175.  
  176.     function sayHello()
  177.     {
  178.         $params = array();
  179.         return $this->send_request('demo.sayHello',$params);
  180.     }
  181.  
  182. }
  183.  
  184. $objXMLRPClientWordPress = new XMLRPClientWordPress("http://9football.net/xmlrpc.php" , "thieumao" , "12345678a@");
  185.  
  186. echo '<table border="1" cellpadding="10">';
  187.  
  188. echo '<tr>';
  189. echo '<td>Request Name</td>';
  190. echo '<td>Result</td>';
  191. echo '</tr>';
  192.  
  193. echo '<tr>';
  194. echo '<td>demo.sayHello</td>';
  195. echo '<td>'.$objXMLRPClientWordPress->sayHello().'</td>';
  196. echo '</tr>';
  197.  
  198. /*
  199. echo '<tr>';
  200. echo '<td>metaWeblog.newPost</td>';
  201. echo '<td>'.$objXMLRPClientWordPress->create_post('Post', 'Noi dung','').'</td>';
  202. echo '</tr>';
  203. */
  204.  
  205. echo '<tr>';
  206. echo '<td>metaWeblog.newPost</td>';
  207. // Up bai viet cho nay
  208. echo '<td>'.$objXMLRPClientWordPress->create_post_football($title, $body, $category, $introtext, $idhinhanh, $idhinhanh, $linksource, $linkserver, $linkyoutube, $linkdropbox, $matchtime, $ishot);
  209. //echo '<td>'.$objXMLRPClientWordPress->create_post_football("Tieu de test 2", "Noi dung test 2", "Thu", "gioi thieu", $idhinhanh, $idhinhanh, "linknguon", "linkserver", "linkyoutube", "linkdropbox", "07/02/2013", "");
  210. echo '</tr>';
  211.  
  212.  
  213. /*
  214. echo '<tr>';
  215. echo '<td>wp.newPage</td>';
  216. echo '<td>'.$objXMLRPClientWordPress->create_page('Page Thu ', 'Noi dung page thu').'</td>';
  217. echo '</tr>';
  218. */
  219.  
  220.  
  221. echo '<tr>';
  222. echo '<td>wp.getAuthors</td>';
  223. echo '<td>'. $objXMLRPClientWordPress->display_authors().'</td>';
  224. echo '</tr>';
  225.  
  226. echo '</table>';
Advertisement
Add Comment
Please, Sign In to add comment