Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. function wpPostXMLRPC($title,$body,$category,$keywords='',$encoding='UTF-8') {
  2. $rpcurl = 'http://example.net/xmlrpc.php';
  3. $username = 'admin';
  4. $password = 'admin';
  5.  
  6. $title = htmlentities($title,ENT_NOQUOTES,$encoding);
  7. $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
  8.  
  9. $content = array(
  10. 'title'=>$title,
  11. 'description'=>$body,
  12. 'mt_allow_comments'=>1, // 1 to allow comments
  13. 'mt_allow_pings'=>0, // 1 to allow trackbacks
  14. 'post_type'=>'post',
  15. 'mt_keywords'=>$keywords,
  16. 'categories'=>array($category)
  17. );
  18. $params = array(0,$username,$password,$content,true);
  19. $request = xmlrpc_encode_request('metaWeblog.newPost',$params);
  20. $ch = curl_init();
  21. curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  22. curl_setopt($ch, CURLOPT_URL, $rpcurl);
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  24. curl_setopt($ch, CURLOPT_TIMEOUT, 1);
  25. $results = curl_exec($ch);
  26. curl_close($ch);
  27. return $results;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement