-1

I'm using metaweblog api to post blogs on wordpress with c# as the language. Everything words like custom fields, tags, category and title. Problem is I can't seem to upload image and set the image as featured image. I've been searching for answers for 4 days already and still no luck. Maybe you guys could help me on this. Thank you very much.

chris_techno25
  • 2,401
  • 5
  • 20
  • 32
  • Maybe you could show us what you've tried so far? –  Sep 13 '13 at 03:35
  • How do i post the whole code here? anywayz, im following this tutorial. http://www.dotnetcurry.com/ShowArticle.aspx?ID=419 of course ive added quite a few additions like category choosing and custom fields which work perfectly... just the image uploading and setting it as featured image that i have a problem with... and i havent dont any working code here, everything ive tried just doesnt work... :( – chris_techno25 Sep 13 '13 at 06:30
  • http://stackoverflow.com/questions/4370140/wordpress-xml-rpc-upload-image-c-sharp http://pixpuffindev.blogspot.in/2012/08/posting-to-wordpress-with-c-using.html – Subharanjan Sep 13 '13 at 07:26

1 Answers1

1

I found the answer to the problem. XML-RPC alone cannot set any uploaded image to featured image. Head over to this issue page http://core.trac.wordpress.org/ticket/15098. The patch allows returning the ID information of the uploaded image when using wp.uploadFile/metaWeblog.newMediaObject. Once the image ID(not the image URL) is returned, you can set it to wp_post_thumbnail and it should appear as featured image. Another workaround without going this route is by uploading the image first and you should be able to retrieve the URL of the image. Query ID information from wordpress database table called wp_posts where image id is equal to the name of the image uploaded. From there, you can then set the ID to wp_post_thumbnail. Thanks a lot.

chris_techno25
  • 2,401
  • 5
  • 20
  • 32