WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack Post Views
[resolved] API key (20 posts)

  1. Topher
    Member
    Posted 1 year ago #

    I first installed this on my dev server and grabbed the views out of the meta info and printed them in my template and it worked GREAT.

    I moved it to live and I'm not seeing the views meta key in my post meta. That's when I read the doc and saw that I need to tell THIS plugin my jetpack API key.

    Why did it work on my dev server without me telling it my API key in some way? I assumed it would use the one in Jetpack.

    I'm running this on a large network, do I need to create a widget on every site, give it the key for that site, and then deactivate the widget? I don't want a widget, but is that the only way to tell this plugin what the API key is?

    Thanks for the advice!

    http://wordpress.org/extend/plugins/jetpack-post-views/

  2. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    I'm not quite sure why it would have worked on your dev server without the API key since the Jetpack API needs that key to access the information. Very interesting.

    The current setup does require that the API key be entered in the widget per site. The way in which you describe how you want to use it tells me I should remove the API key from the widget and put a plugin settings page where you enter the key. This is probably how it should be anyway, plus it would let me implement the other settings I'm working on better. Thanks for the support request so I could think about it this way.

  3. Topher
    Member
    Posted 1 year ago #

    That would be really fantastic. Do you have a timeframe in mind for that?

    Until then, I can make a widget, put the key in, and then move the widget to the inactive area?

  4. Topher
    Member
    Posted 1 year ago #

    I see there's an option in the options table for jetpack_post_views_wp_api_key Can I simply put it in there?

  5. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    Moving the widget to the inactive area will work just fine after the API Key has been entered. If you feel confident with the PHP code you could just hard code the API key to the options table, though the function to grab all the post view information is only ran either every hour or when you click the save button on the widget.

  6. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    I would love to get the new version released this weekend, but it depends if I'm able to put in as much time as I would like to.

  7. Topher
    Member
    Posted 1 year ago #

    I'm happy to test or help if needs be. I really need it. :) Your chosen mechanism for making the data available is wonderful. :)

  8. Topher
    Member
    Posted 1 year ago #

    I'm trying to think of a way to make this work without having to put our API key in. Doesn't Jetpack already store the API key in the options table? Is there any way to reference that?

  9. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    I tried that at first, but as far as I can tell, WordPress does not store it's own API Key in the database at all. I searched for it using PhPMyAdmin, and nothing came up. So I was forced to find it a different way and the api.wordpress.com site is the only way I found. :( I wish it stored it in the database so I could reference it.

  10. Topher
    Member
    Posted 1 year ago #

    It looks like stats_get_csv() will get the data you need. Something like this:

    if (function_exists('stats_get_csv')) {
    global $post_stats;
    $post_stats = stats_get_csv('postviews', '&days=-1&limit=-1&summarize');
    }

    It simply asks jetpack for it, rather than hitting the server again.

  11. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    I tried that function in my dev environment, and it didn't exist. I never did try it in my production environment though, so I'll give it a try. But I think that function not existing might be the reason http://wordpress.org/extend/plugins/wordpresscom-popular-posts/ stop being actively developed. I'll let you know what I find later today.

  12. Topher
    Member
    Posted 1 year ago #

    That would make sense, I found yours because posts-n-pages quit working for us.

    That said, the function exists in jetpack. I haven't done any research to see if it's still working. I can do a post in their support area to see if it'll still work.

  13. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    So it seems that the function exists on my production environment, so I can use it as the primary source for the information (it's more up to date anyway for the stats). I'll still have options for entering API information if for some reason the function doesn't exist.

  14. Topher
    Member
    Posted 1 year ago #

    Yep. That function comes from Jetpack, so as long as you have that on your dev machine it should be there.

    Are you still thinking of doing it this weekend? I like your method of making the data available more than the plugin I've been using.

  15. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    Ya, the plan is still to get the new version out this weekend.

  16. Topher
    Member
    Posted 1 year ago #

    Awesome, I'll be on all weekend, happy to test. Can you see my email address?

  17. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    I found the problem with my dev environment. I do have Jetpack installed but it wans't linked to WordPress.com (because it's a local test server). Not being able to connect to WordPress makes the stats_get_csv() function nonexistant.

    I don't see your email address, but I'll post in this thread a link to a testable .zip file when I have it ready to test. Thanks for helping me out.

  18. Topher
    Member
    Posted 1 year ago #

    You bet, I'm excited.

  19. Steven Lambert
    Member
    Plugin Author

    Posted 1 year ago #

    Alright Topher, here is the link to the new version for your testing pleasure. Let me know if everything works out for you or if you run into any problems. Thanks for testing.

    http://sklambert.com/jetpack-post-views.zip

  20. Topher
    Member
    Posted 1 year ago #

    Awesome, instaled and testing.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags