Home > Doing Good > Kiva Loans WordPress Widget

Kiva Loans WordPress Widget

This is the Kiva Loans WordPress Widget page, which includes the technical details and instructions for the widget. Please direct any questions or comments to the comments of this post. If you would like to read about my experience in building the Kiva.org Loans Widget, please read this post.

Kiva.org Loans Widget Description

Kiva Loans sidebar widget allows the user to display their public loans from Kiva.or on their blog. The user specifies their Kiva lender name, the number of loans (N) to show, and the size of the images that will be displayed. The widget then randomly selects N of the user’s loans from the Kiva API, and displays brief information about each of them. Links to the Kiva.org website

If you have marked any of your Kiva loans as private, or have lent anonymously, your loans will not show up in the Kiva Loans Widget. Only public loans are available to the Kiva.org Loans Widget.

Important: This Kiva Widget requires your Kiva Lender Name. This is not your email that you use to login to Kiva.org! Your Kiva Lender Name is the name Kiva uses in the URL for your Kiva Lender Page. You can access and change your Kiva Lender Name via the last item on “My Lender Page” under “My Portfolio” on Kiva.org.

Installation and Configuration Instructions

1. Download the zip file from accessible from the WordPress Plugins space
2. Upload and unzip into the plugins directory ( /wp-content/plugins/ ) on your server
3. Activate the plugin through the ‘Plugins’ menu in WordPress
3. Add the widget to a sidebar via the ‘Widgets’ page under the ‘Appearance’ menu
4. Set the options, and save your settings

Kiva.org Loans Widget Options

Kiva Lender Name: Your Kiva Lender Name, from “My Lender Page URL” on Kiva
Number of loans: The number you Kiva loans you would like to be displayed
Image Size: The maximum width, or height (which ever is larger) of the image in pixels

FAQ

What is Kiva.org?

A micro-lending site. http://kiva.org

Will it show private loans?

No, it will only show your public Kiva loans.

How do I change the look of the Kiva Loans Widget?

The style sheet is in the plugin folder at /wp-content/plugins/kiva-widget/style.css

What if I get the json_decode error?

Fatal error: Call to undefined function: json_decode() in wp-content/plugins/kivaorg-widget/kiva.php

This error means that you do not have PHP JSON’s support installed on your server. JSON support became a part of the PHP core in PHP 5.2.0. The best way to handle this error is to upgrade your PHP to the newest stable available version. Most Linux distributions will have packages for upgrading. On Windows, you can go to the PHP Downloads page. For more information, check out the PHP JSON Manual.

What if I get the Permission Denied error

Warning: fopen( wp-content/plugins/kivaorg-widget/cache/kiva_cache_1241553368.txt) [function.fopen]: failed to open stream: Permission denied

This error means that improper permissions are set within the Kiva widget directory on your server. The directory ‘cache’ within the widget must be writable by your server’s web users. You can fix this problem by changing the ownership of the directory ‘cache’ to the web user. Most likely one of the following command will work, if performed within the plugin directory ( wp-content/plugins ):

chown www-data:www-data kivaorg-widget/cache

or

chmod 777 /kivaord-widget/cache

Screenshots

The widget displayed on the side bar

The widget displayed on the side bar

The widget's admin control

The widget's admin control

I hope you enjoy the widget, and love Kiva as much as I do! Please do not hesitate to send questions and comments via the comments of this post. Happy micro-lending!

You might also like...

Categories: Doing Good Tags: ,
  1. February 7th, 2009 at 12:24 | #1

    Marilyn,

    Question. I installed the Kiva widget for WordPress, but it doesn’t work. It says that I don’t have any Kiva loans. Au contraire! What I think is missing in your code is the Kiva user password. I put in my username, but without the password, it doesn’t open my account. Can you fix this and post the new widget? I really love Kiva and want to show them at my blog: http://www.chrysalispublications.com/wordpress

    Many thanks – in advance.

    Carol Plotnick

  2. February 7th, 2009 at 13:32 | #2

    Hi Marilyn,

    Just installed your Kiva plugin. I got this failure in the side:

    Warning: array_fill() [function.array-fill]: Number of elements must be positive in /customers/margrieten.nl/margrieten.nl/httpd.www/wp-content/plugins/kivaorg-widget/kiva.php on line 79

    When I put in somebody else number, there is nothing wrong, but when I put my username in, it goes wrong!
    Is it because I just lend?

  3. May 6th, 2009 at 01:33 | #3

    Hi Marylin,
    I’m having the same problem as Carol. On my website the widget is saying I have not made any loans. I’ve made 17 to date. Can you tell me how I can change this? I would like to display this widget but I look like an idiot for soliciting for Kiva but looking like I haven’t supported them myself.
    Thanks,
    Alice
    http://savorysweetlife.com

    • May 6th, 2009 at 20:14 | #4

      Hi Alice.

      What are you using for your Kiva Lender Name in the widget? This is a point of confusion with the Kiva system. The widget is expecting the value entered in “My Lender Page URL” under “My Lender Page”, not your email address. If you log into Kiva, then go to: https://www.kiva.org/app.php?page=account&action=lenderPageEdit, you can view and edit this value.

      If this doesn’t solve your problem, please let me know, I’ll be happy to investigate further.

      Marilyn

  4. May 6th, 2009 at 05:23 | #5

    With all due respect, most of us don’t have our own server which we can upgrade and my otherwise terrific host (no need to advise switching because I won’t) won’t install that JSON thingy. Alas, no Kiva on my blog…

  5. May 6th, 2009 at 12:46 | #6

    Afke, I’m sorry that your host has not kept it’s PHP distribution up to date. PHP’s JSON support came out in 2006. I’d be wary of a host that is that out of date!

  6. May 16th, 2009 at 18:17 | #7

    Is there a way to use a lending team’s account rather than a single user’s? The team URL uses /team/username rather than /lender/username.

    • May 18th, 2009 at 21:09 | #8

      Hi Kara,

      This is possible, but I’ll have to program it into the widget. It’s a good idea, so I figure I likely will make some time to program it in. I’ll drop you a line when I’ve had the chance to do so. Thanks for the suggestion!

      • August 31st, 2009 at 09:54 | #9

        I would also love a team widget if you do come up with one.

  7. May 23rd, 2009 at 21:52 | #10

    Nice widget, I’ll try to install it.

  8. June 3rd, 2009 at 00:26 | #11

    Hi Marilyn! This widget was a great idea — thanks for your efforts in putting it together. Unfortunately, the images don’t seem to be loading my blog (link provided along with my commenter details) — any advice?

    • June 3rd, 2009 at 11:48 | #12

      Hi jL! From looking at your blog, I’m not sure what exactly is going on. I suspect it’s a permissions issue. Do you have ftp/ssh access to your server? If so, please check that the plugin’s cache directory is writable. (uncarved.prometheas.com/wp-content/plugins/kivaorg-widget/cache/) Are there any images in that directory? If not, then this is the problem. You can fix this by changing the permissions on the cache directory from the root of your wordpress:

      chmod 777 wp-content/plugins/kivaorg-widget/cache/

      If this doesn’t work for you, please let me know, I’ll be happy to try to help further!

  9. June 7th, 2009 at 02:06 | #13

    Hey girl!

    So I fixed the issue. Perms were fine, but I added a declaration of CURLOPT_RETURNTRANSFER with a value of true in the build_html() function:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    $image = curl_exec ($ch);

    Every works fine now! Wonder why this bit my ass and no-one else’s tho…… ah, Diversity, you old dog.

  10. July 7th, 2009 at 06:22 | #15

    Hi Marilyn,
    I receive this error when running the widget. Any insights on what I can modify to get it to work?

    Warning: fopen(/home/ispithot/public_html/Wordpress/wp-content/plugins/kivaorg-widget/cache/kiva_cache_1246947616.txt) [function.fopen]: failed to open stream: No such file or directory in /home/ispithot/public_html/Wordpress/wp-content/plugins/kivaorg-widget/kiva.php on line 193
    can't open file: /home/ispithot/public_html/Wordpress/wp-content/plugins/kivaorg-widget/cache/kiva_cache_1246947616.txt

    Thanks!

  11. July 11th, 2009 at 03:53 | #16

    Thanks for the plugin Marilyn- actually should I call you Urpi?

  12. July 13th, 2009 at 02:09 | #18

    Marilyn,

    I am using WordPress 2.8.1 and your widget is not showing my loans. I am using the correct Kiva name (from the lender page not my email address) and my PHP is up to date. When I installed the widget there was a warning that your widget had not been tested with this version. When I place the widget in my sidebar it says I have no loans. Is this a version conflict and if so will you fix it?

    • July 13th, 2009 at 23:13 | #19

      Hi Shannon.

      I just released a newer version of the Kiva plugin that works on 2.8.1 for me. Install the new plugin from within the wordpress interface, and it should be installed properly.

      If you continue to have problems, please contact me again with more details, including the blog address where the plugin is not working, and your Kiva lender name. Feel free to email me at marilyn[at]urpisdream[dot]com if you do not want to publish that information.

  13. July 16th, 2009 at 07:49 | #21

    great plugin..

    im having a little plugin.. not all my loans are showing.. its showing 15 out of the 30 that i did.. i already set it to show 150.. thnx in advance..

    where did you get urpi?

  14. July 21st, 2009 at 17:34 | #22

    Pretty cool post. I just stumbled upon your blog and wanted to say
    that I have really liked reading your blog posts. Anyway
    I’ll be subscribing to your blog and I hope you post again soon!

  15. October 20th, 2009 at 14:20 | #23

    Thank your site for your helping hand.

  16. October 22nd, 2009 at 17:23 | #24

    As they discuss these matters, they can come to appreciate the different dimensions of a problem. ,

  17. November 26th, 2009 at 15:35 | #25

    Truthful words, some true words dude. Made my day!

  1. July 9th, 2009 at 23:39 | #1