Now you can integrate sweetie-giving into your own app!

Sweetie-giving links can be attached to any content object you're displaying. Clicking the link will take the user to the sweetie-giving form.

As an example, suppose you have a photo-sharing app, and you want users to be able to drop sweeties on photos that they particularly like.
Simply add a "drop a sweetie on this!" link next to or below each photo, with the link formed like so:

http://sweeties.ning.com/give.php?recip_id=538126&giver_app=photosharingwithsweeties&url=http%3A%2F%2Fphotosharingwithsweeties.ning.com%2Findex.php

... where...

recip_id
is the ID of the content object (in this case, a photo)
giver_app
is the URL-name of your app
url
is the URL to which the user should be returned after the transaction

You can also make links that give sweeties directly to users without being linked to a content object. Make a URL like this:

http://sweeties.ning.com/give.php?recip_user=bob&giver_app=photosharingwithsweeties&url=http%3A%2F%2Fphotosharingwithsweeties.ning.com%2Findex.php

... where...

recip_user
is the screenname of the user who contributed the content object
giver_app
is the URL-name of your app
url
is the URL to which the user should be returned after the transaction

Code examples

Here's how the sweetie-giving links were added to Photo Sharing to make Photo Sharing With Sweeties. The links were added to two template pages which output single photos: photo.template.thumb.php outputs a photo thumbnail for pages that show a list of photos, and photo.template.detail.php outputs a detail page for a single photo.

In the file photo.template.thumb.php, the two bolded lines were added to the code that builds the links under the thumbnail:

echo $numberViews . ' | <a href="?action=photo&id=' . $object->id .'#comments">' . $numberComments . '</a><br/>';
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo '<a href="http://sweeties.ning.com/give.php?recip_id='.($object->id).'&giver_app=photosharingwithsweeties&url='.urlencode($url).'">give a sweetie</a><br/>';
echo 'Posted ' . $date . ' ';

In line 2, $url is created to store the URL to which the user will be redirected after the transaction. For this, we're using the URL of current page that the user is looking at. (You can use any URL you like, but most users will want to be returned to where they were before.)

Line 3 constructs and outputs the link tag for sweetie giving. For the recip_id argument, we use the ID of the current content object being displayed. The object's conveniently already in $object, so we can just output the ID with $object->id. Also, we output $url with the urlencode() function so that it doesn't mangle the link.