Skip to content
This repository was archived by the owner on Aug 22, 2019. It is now read-only.

Assertions

Brian J Brennan edited this page Sep 9, 2011 · 32 revisions

Signed

In the future we will support signed assertions, which will mean signing a badge assertion with your private key and hosting a public key at a well known, public URL. In the even more distant future, we will probably try to support DNSSEC for public key discovery. For now, we only support Hosted Assertions.

Hosted

A hosted assertion is a file containing well-formatted JSON served with the content-type application/json.

Setting Content-Type

In the examples below badge_manifest is a native dictionary, hash or associative array. badge_manifest_json is a prepared JSON string.

PHP

// Do this before doing anything that starts a response
header('Content-Type: application/json');

Drupal 6

// do not use drupal_json -- it sets the wrong header
drupal_add_http_header('Content-Type', 'application/json');
echo drupal_to_js(badge_manifest);

Drupal 7

drupal_json_output(badge_manifest);

Django

HttpResponse(badge_manifest_json, mimetype='application/json')

Rails

render :json => badge_manifest

Apache

# Save your assertions as .json files and add this to your httpd.conf
AddType application/json        json

Nginx

# In your server context, add the following:
types {
  applications/json     json;
}

Clone this wiki locally