Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class XMLRPClientWordPress
- {
- /*
- var $XMLRPCURL = "http://9football.net/xmlrpc.php";
- var $UserName = "admin";
- var $PassWord = "123456789a@";
- */
- var $XMLRPCURL;
- var $UserName;
- var $PassWord;
- // constructor
- public function __construct($xmlrpcurl, $username, $password)
- {
- $this->XMLRPCURL = $xmlrpcurl;
- $this->UserName = $username;
- $this->PassWord = $password;
- }
- function send_request($requestname, $params)
- {
- //$request = xmlrpc_encode_request($requestname, $params);
- $request = xmlrpc_encode_request('metaWeblog.newPost',$params,array('encoding'=>'UTF-8','escaping'=>'markup'));
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
- curl_setopt($ch, CURLOPT_URL, $this->XMLRPCURL);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 1);
- $results = curl_exec($ch);
- curl_close($ch);
- return $results;
- }
- function create_post($title,$body,$category,$keywords='',$encoding='UTF-8')
- {
- $title = htmlentities($title,ENT_NOQUOTES,$encoding);
- $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
- $content = array(
- 'title'=>$title,
- 'description'=>$body,
- 'mt_allow_comments'=>0, // 1 to allow comments
- 'mt_allow_pings'=>0, // 1 to allow trackbacks
- 'post_type'=>'post',
- 'mt_keywords'=>$keywords,
- /*
- "custom_fields" => array(
- array( 'key' => 'linksource', 'value' => 'linksource ngay valentin' ),
- array( 'key' => '_linksource', 'value' => 'field_52f1e88803f57'),
- array( 'key' => 'matchtime', 'value' => '14/02/2014' ),
- array( 'key' => '_matchtime', 'value' => 'field_52f1e88805c33')
- ),
- */
- 'categories'=>array($category)
- );
- $params = array(0,$this->UserName,$this->PassWord,$content,false);
- return $this->send_request('metaWeblog.newPost',$params);
- }
- function create_post_tivi($post_type,$title,$body,$category,$icon,$tiviid,$description,$link1,$link2,$link3,$link4,$isdefault,$arrURL,$arrDescription,$keywords='',$encoding='UTF-8')
- {
- $title = htmlentities($title,ENT_NOQUOTES,$encoding);
- $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
- $count = count($arrURL);
- /*
- $content['title'] = $title;
- $content['description'] = $body;
- $content['mt_allow_comments'] = 1;
- $content['mt_allow_pings'] = 1;
- $content['mt_allow_pings'] = $post_type;
- $content['mt_keywords'] = $keywords;
- */
- /*
- $arr_custom_fields = array();
- array_push($arr_custom_fields ,array( 'key' => 'icon', 'value' => $icon ));
- array_push($arr_custom_fields,array( 'key' => '_icon', 'value' => 'field_531eb2f70a7bc'));
- array_push($arr_custom_fields,array( 'key' => 'tiviid', 'value' => $tiviid ));
- array_push($arr_custom_fields,array( 'key' => '_tiviid', 'value' => 'field_531eb2f70ac7a'));
- array_push($arr_custom_fields,array( 'key' => 'description', 'value' => $description ));
- array_push($arr_custom_fields,array( 'key' => '_description', 'value' => 'field_531eb2f70b124'));
- array_push($arr_custom_fields,array( 'key' => 'link1', 'value' => $link1 ));
- array_push($arr_custom_fields,array( 'key' => '_link1', 'value' => 'field_52f1e88803f57'));
- array_push($arr_custom_fields,array( 'key' => 'link2', 'value' => $link2 ));
- array_push($arr_custom_fields,array( 'key' => '_link2', 'value' => 'field_531eb2f70ba9a'));
- array_push($arr_custom_fields,array( 'key' => 'link3', 'value' => $link3 ));
- array_push($arr_custom_fields,array( 'key' => '_link3', 'value' => 'field_531eb2f70bf70'));
- array_push($arr_custom_fields,array( 'key' => 'link4', 'value' => $link4 ));
- array_push($arr_custom_fields,array( 'key' => '_link4', 'value' => 'field_531eb2f70c438'));
- array_push($arr_custom_fields,array( 'key' => 'isdefault', 'value' => $isdefault ));
- array_push($arr_custom_fields,array( 'key' => '_isdefault', 'value' => 'field_531eb2f70c91b'));
- for ($i = 0; $i < $count; $i++) {
- array_push($arr_custom_fields,array( 'key' => 'linkstream_'.$i.'_url', 'value' => $arrURL[$i]));
- array_push($arr_custom_fields,array( 'key' => '_linkstream_'.$i.'_url', 'value' => 'field_5323d3cb82ae9'));
- array_push($arr_custom_fields,array( 'key' => 'linkstream_'.$i.'_description', 'value' => $arrDescription[$i]));
- array_push($arr_custom_fields,array( 'key' => '_linkstream_'.$i.'_description', 'value' => 'field_5323d3cb82a91'));
- }
- $content = array(
- 'title'=>$title,
- 'description'=>$body,
- 'mt_allow_comments'=>1, // 1 to allow comments
- 'mt_allow_pings'=>1, // 1 to allow trackbacks
- 'post_type'=>$post_type, // post
- // 'post_status' => 'inherit'
- 'mt_keywords'=>$keywords,
- //"custom_fields" =>$arr_custom_fields,
- 'categories'=>array($category)
- );
- */
- echo "1123";
- $content = array(
- 'title'=>$title,
- 'description'=>$body,
- 'mt_allow_comments'=>0, // 1 to allow comments
- 'mt_allow_pings'=>0, // 1 to allow trackbacks
- 'post_type'=>'post',
- 'mt_keywords'=>$keywords,
- /*
- "custom_fields" => array(
- array( 'key' => 'linksource', 'value' => 'linksource ngay valentin' ),
- array( 'key' => '_linksource', 'value' => 'field_52f1e88803f57'),
- array( 'key' => 'matchtime', 'value' => '14/02/2014' ),
- array( 'key' => '_matchtime', 'value' => 'field_52f1e88805c33')
- ),
- */
- 'categories'=>array($category)
- );
- $params = array(0,$this->UserName,$this->PassWord,$content,true);
- return $this->send_request('metaWeblog.newPost',$params);
- }
- function create_post_football($title,$body,$category,$introtext,$imageFull,$thumbnail,$linksource,
- $linkserver,$linkyoutube,$linkdropbox,$matchtime,$ishot,$keywords='',$encoding='UTF-8')
- {
- $title = htmlentities($title,ENT_NOQUOTES,$encoding);
- $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
- $content = array(
- 'title'=>$title,
- 'description'=>$body,
- 'mt_allow_comments'=>1, // 1 to allow comments
- 'mt_allow_pings'=>1, // 1 to allow trackbacks
- 'post_type'=>'post',
- 'mt_keywords'=>$keywords,
- "custom_fields" => array(
- array( 'key' => 'introtext', 'value' => $introtext ),
- array( 'key' => '_introtext', 'value' => 'field_52f1e887ee97f'),
- array( 'key' => 'imageFull', 'value' => $imageFull ),
- array( 'key' => '_imageFull', 'value' => 'field_52f1e887ef089'),
- array( 'key' => 'thumbnail', 'value' => $thumbnail ),
- array( 'key' => '_thumbnail', 'value' => 'field_52f1e887ef759'),
- array( 'key' => 'linksource', 'value' => $linksource ),
- array( 'key' => '_linksource', 'value' => 'field_52f1e88803f57'),
- array( 'key' => 'linkserver', 'value' => $linkserver ),
- array( 'key' => '_linkserver', 'value' => 'field_52f1e88804684'),
- array( 'key' => 'linkyoutube', 'value' => $linkyoutube ),
- array( 'key' => '_linkyoutube', 'value' => 'field_52f1e88804d93'),
- array( 'key' => 'linkdropbox', 'value' => $linkdropbox ),
- array( 'key' => '_linkdropbox', 'value' => 'field_52f1e888054e4'),
- array( 'key' => 'matchtime', 'value' => $matchtime ),
- array( 'key' => '_matchtime', 'value' => 'field_52f1e88805c33'),
- array( 'key' => 'ishot', 'value' => $ishot ),
- array( 'key' => '_ishot', 'value' => 'field_52f1e888063a4'),
- ),
- 'categories'=>array($category)
- );
- $params = array(0,$this->UserName,$this->PassWord,$content,true);
- return $this->send_request('metaWeblog.newPost',$params);
- }
- function create_page($title,$body,$encoding='UTF-8')
- {
- $title = htmlentities($title,ENT_NOQUOTES,$encoding);
- $content = array(
- 'title'=>$title,
- 'description'=>$body
- );
- $params = array(0,$this->UserName,$this->PassWord,$content,true);
- return $this->send_request('wp.newPage',$params);
- }
- function display_authors()
- {
- $params = array(0,$this->UserName,$this->PassWord);
- return $this->send_request('wp.getAuthors',$params);
- }
- function sayHello()
- {
- $params = array();
- return $this->send_request('demo.sayHello',$params);
- }
- }
- $objXMLRPClientWordPress = new XMLRPClientWordPress("http://tivi.9appstore.com/xmlrpc.php" , "thieumao" , "12345678a@");
- //$objXMLRPClientWordPress->create_post('Post thu ma 2', 'Noi dung thu ma','');
- $post_type='post';
- $title="tuan11111111111111111111111111";
- $body="thieumao body";
- $category="Gi?i Trí";
- $icon=48;
- $tiviid="thieumao tiviid";
- $description="thieumao des";
- $link1="thieumao 1";
- $link2="thieumao 2";
- $link3="thieumao 3";
- $link4="thieumao 4";
- $isdefault="thieumao isdefault";
- $arrURL = array('http://tuan.com','http:tuann1.com','http://tuann2.com');
- $arrDescription = array('net ','cuc net','sieu cuc net');
- $objXMLRPClientWordPress->create_post_tivi($post_type,$title,$body,$category,$icon,$tiviid,$description,$link1,$link2,$link3,$link4,$isdefault,$arrURL,$arrDescription);
- echo "thanh cong12344";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment