Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

OpenBadges.issue() should be able to take a string or an array #167

Rudloff opened this Issue May 17, 2012 · 3 comments


None yet
3 participants

Rudloff commented May 17, 2012

One of my projects uses badges. When the user clicks on one of his badges, he can import it to its backpack.
But, when I click on a badge, it says "You are about to submit 65 badges" (!?).
If I click "Cool, let's go!", the popup becomes blank and nothing happens.

Here is the output of the console:

Horodatage : 17/05/2012 19:27:13
Erreur : assertions.pop is not a function
Fichier Source : http://beta.openbadges.org/js/issuer-frame.js
Ligne : 446

Using Firebug, I also noticed this:

"NetworkError: 404 Not Found - http://beta.openbadges.org/issuer/%5B%5Bassertion.badge.image%5D%5D"
"NetworkError: 400 Bad Request - http://beta.openbadges.org/issuer/assertion?url=1"

Here is my JS code:

/*global $, OpenBadges*/
var i;
function getUrlVars() {
    "use strict";
    var vars, parts;
    vars = {};
    parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    return vars;
var GET = getUrlVars();

var issueBadge = function (e) {
    "use strict";
    var type = e.target.getAttribute("data-type") || e.target.parentNode.getAttribute("data-type");
    OpenBadges.issue("http://strasweb.fr/projets/assoquest/assertion.php?badge=" + type + "&user=" + GET.user);

var getBadges = function () {
    "use strict";
    $(".badge").bind("vclick", issueBadge);

$(document).bind("pageinit", getBadges);

And here is one of my assertions:

Am I doing something wrong?


brianloveswords commented May 25, 2012


OpenBadges.issue takes an array as a first param so it can accept multiple badges at once. Your code should read

    OpenBadges.issue(["http://strasweb.fr/projets/assoquest/assertion.php?badge=" + type + "&user=" + GET.user]);

That's why you're getting 65 badges:

"http://strasweb.fr/projets/assoquest/assertion.php?badge=1&user=1".length === 65

You can fix this now by passing in an array, but I'm leaving this open because it's bad behavior for the API to not take a string when there is a single badge being issued.

Rudloff commented May 26, 2012

Oh yes, it works with an array, sorry about that.


stenington commented Nov 20, 2012

I believe this is fixed.

@stenington stenington closed this Nov 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment