Title: halcyonyarn's Replies | WordPress.org

---

# halcyonyarn

  [  ](https://wordpress.org/support/users/halcyonyarn/)

 *   [Profile](https://wordpress.org/support/users/halcyonyarn/)
 *   [Topics Started](https://wordpress.org/support/users/halcyonyarn/topics/)
 *   [Replies Created](https://wordpress.org/support/users/halcyonyarn/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/halcyonyarn/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/halcyonyarn/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/halcyonyarn/engagements/)
 *   [Favorites](https://wordpress.org/support/users/halcyonyarn/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Variation Swatches for WooCommerce] Using with WooCommerce REST API](https://wordpress.org/support/topic/using-with-woocommerce-rest-api/)
 *  [halcyonyarn](https://wordpress.org/support/users/halcyonyarn/)
 * (@halcyonyarn)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/using-with-woocommerce-rest-api/#post-10125642)
 * I had the same problem, but with image swatches. I don’t think it’s possible 
   with the WooCommerce API only to update all that is needed since you have to 
   mess about with “term_meta” and term_taxonomies and etc. After wrestling with
   authentication difficulties using the wordpress REST API, I decided to go with
   old-faithful xmlrpc. This code could be re-written as a plugin (my plan) but 
   for now it can just be put up on your server somewhere. I call this code from
   our custom db solution via CURL. It’s rough, but, might give anyone else wondering
   about this a starting point. It requires multiple calls to retrieve, delete/update/
   add those parts of the term_meta that can’t be set via the WooCommerce API. WordPress
   xmlrpc documentation is your friend.
 *     ```
       <?
       if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){ echo "ur doin it wrong https is better"; exit(); }
   
       $protocol='https://';
   
       $username=$_POST['username'];
       $password=$_POST['password'];
       $blogid=1; //Post ID
       $xmlrpcurl=$protocol.'URL-TO-YOUR-BLOG.com/xmlrpc.php';
   
       if($_POST['filename'] && $_POST['action']=="wp.uploadFile"){
               $item=$_POST['filename'];
               $prefix=$_POST['prefix'];
               $file=file_get_contents('https://URL-TO-YOUR-IMAGES.com/'.$filename.'.jpg');
               $filetype = "image/jpeg";
               $filename = $filename.".jpg";
               xmlrpc_set_type($file,'base64'); // <-- required!
   
               $params = array($blogid,$username,$password,
                               array('name'=>$filename,'type'=>$filetype,'bits'=>$file,'overwrite'=>false));
               $request = xmlrpc_encode_request('wp.uploadFile',$params);
       }elseif($_POST['postid'] && $_POST['action']=="wp.deletePost"){
               $postid=$_POST['postid'];
               $params = array($blogid,$username,$password, $postid);
               $request = xmlrpc_encode_request('wp.deletePost',$params);
       }elseif($_POST['termid'] && $_POST['action']=="wp.editTerm"){
               $taxonomy=$_POST['taxonomy'];
               $termid=$_POST['termid'];
               $meta[]=array('key'=>$_POST['key'],'value'=>$_POST['value']);
               $metaParam=array('custom_fields'=>$meta, 'taxonomy'=>$taxonomy);
               $params = array($blogid,$username,$password, $termid,$metaParam);
               $request = xmlrpc_encode_request('wp.editTerm',$params);
       }elseif($_POST['taxonomy'] && $_POST['action']=="wp.getTerms"){
               $taxonomy=$_POST['taxonomy'];
               $params = array($blogid,$username,$password,$taxonomy);
               $request = xmlrpc_encode_request('wp.getTerms',$params);
       }elseif($_POST['taxonomy'] && $_POST['termid'] && $_POST['action']=="wp.deleteTerm"){
               $termid=$_POST['termid'];
               $taxonomy=$_POST['taxonomy'];
               $params = array($blogid,$username,$password,$taxonomy, $termid);
               $request = xmlrpc_encode_request('wp.deleteTerm',$params);
       }else{
               echo '{"error":"no requests"}';
       }
   
       if($request){
               $result = go($request,$xmlrpcurl);
               $json_result = json_encode($result);
   
               echo $json_result;
   
       }else{
               echo '{"error":"no data"}';
       }
       function go($request,$xmlrpcurl){
               $ch = curl_init();
               curl_setopt($ch,CURLOPT_POST,1);
               curl_setopt($ch,CURLOPT_URL,$xmlrpcurl);
               curl_setopt($ch,CURLOPT_POSTFIELDS,$request );
               curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
               $result = curl_exec($ch);
               if($result){
                       return xmlrpc_decode($result);
               }else{
                       echo '{"error":"no url or data encoded"}';
               }
       }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Application Passwords] The Generated Password](https://wordpress.org/support/topic/the-generated-password/)
 *  [halcyonyarn](https://wordpress.org/support/users/halcyonyarn/)
 * (@halcyonyarn)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/the-generated-password/#post-9966465)
 * Gah, oops, that wasn’t the issue after all… I too am not having luck with this
   plugin.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Application Passwords] The Generated Password](https://wordpress.org/support/topic/the-generated-password/)
 *  [halcyonyarn](https://wordpress.org/support/users/halcyonyarn/)
 * (@halcyonyarn)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/the-generated-password/#post-9966124)
 * I had the same trouble, it appears that the spaces in the password are for readability:
   they should be removed before encoding the name:password string.

Viewing 3 replies - 1 through 3 (of 3 total)