Open neatville opened 7 years ago
My bad, I'll update the readme to be more clear. This should work for you I believe:
import wordpress_json as _wp
wp = _wp.WordpressJsonWrapper(...)
Thanks. As far as I know I followed the other instructions correctly. This line posts = wp.get_posts()
supposedly gave me an error, and I was wondering if that sounds familiar with this module or how I could fix that.
http_response.headers.get('Content-Type')]))
wordpress_json.WordpressError: Expected JSON response but got text/html; charset="UTF-8"
Did you change the permalink setting in WordPress to Post name
?
Yeah, it was already using Post name.
I have the same problem:
http_response.headers.get('Content-Type')]))
wordpress_json.WordpressError: Expected JSON response but got text/html
If I print the response I get
b'<html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("684e3935c9332591f5bc89229e2c4982");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://myblog.myblog.org/wp-json/wp/v2/posts?i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>'
Hi @neatville @LuisMars,
Thanks for your feedback. Unfortunately I'm not able to provide support for these issues at the moment.
At the time that we wrote this wrapper, the JSON API was a plugin for Wordpress, and we only supported Basic Auth for authentication. Since version 4.7, the plugin was added to core Wordpress, and I don't think Basic Auth works any more. I believe we need to update this lib to work for 4.7, and for that I would need to also support a different form of authentication.
In short, I'm not sure it makes sense for us to troubleshoot these issues until that underlying problem is fixed, which may take some time.
@LuisMars, @neatville,
I currently don't have much time either, but I spun up a fresh Wordpress 4.7.3, installed the Basic Auth plugin as mentioned in the instructions, changed the permalink settings to "post name" and was able to retrieve posts. Can you maybe provide a few more details on how you are using this wrapper?
I didn't see what exactly I'm supposed to import under basic usage, or anywhere.
ModuleNotFoundError: No module named 'WordpressJsonWrapper'