DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • mxGraph Usage in TypeScript Projects
  • Java and JavaScript Integration in OSGI
  • Freedom to Code on Low-Code Platforms
  • The Emergence of Cloud-Native Integration Patterns in Modern Enterprises

Trending

  • Decoding Business Source Licensing: A New Software Licensing Model
  • Chronicle Services: Low Latency Java Microservices Without Pain
  • Navigating the Skies
  • Breaking Down Silos: The Importance of Collaboration in Solution Architecture
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. First Draft: A JavaScript Library for Behance Integration

First Draft: A JavaScript Library for Behance Integration

Raymond Camden user avatar by
Raymond Camden
·
Oct. 18, 13 · Interview
Like (0)
Save
Tweet
Share
3.38K Views

Join the DZone community and get the full member experience.

Join For Free

Back in April of this year I blogged about how you could create a "widget" version of your Behance portfolio on your web site. This was done using a little library I built and a user's RSS feed. By using the RSS feed we could bypass the somewhat strict limits on the Behance API (150 hits per hour). I had a few people ask about using the real API so I decided to take a stab at it today.

I've begun with the simplest use case imaginable, getting the projects for a single user. First, you begin with your HTML template.

<!doctype html>
<html lang="en">
	<head>
	</head>
	
	<body>
		
		<h1>Regular Site</h1>
		
		<p>
		Some vanilla content.
		</p>

		<h1>My Projects</h1>
		<div id="projects">
		
		</div>
		
		<script src="jquery-2.0.0.min.js"></script>
		<script src="behance_api.js"></script>
		<script src="demo1.js"></script>
	</body>
</html>

Nothing special here. I've got a basic template with an empty div block I'll be using to display my templates. I'm loading jQuery as a dependency, my new library, and demo1.js, which is just the JavaScript file for this page. Let's look at that next.

/* global $,console,document,behanceAPI */
var behancekey = "vNvOiZI0cD9yfx0z4es9Ix6r4L2J7KdI";

$(document).ready(function() {
	
	//Set my key
	behanceAPI.setKey(behancekey);
	
	//Now get my projects
	behanceAPI.getProjects("gwilson", function(p) {

		//Manually draw them out	
		console.dir(p);
		var s = "";
		for(var i=0; i<p.length; i++) {
			var proj = p[i];
			s += "<h2>" + proj.name + "</h2>";
			s += "<p>";
			s += "<a href='" + proj.url + "'><img src='" + proj.covers[404] + "'></a>";
			s += "</p>";
		}
		$("#projects").html(s);
	});

});

In this demo, all I'm doing is setting the API key (see note below) and then running the getProjects call. The method takes two arguments - the user and the function to run after the data has been fetched. I do not have any error handling yet, that will come later. The result is simply an array of projects that you can display however you want. In this case I just create a big ugly string. Typically you would want to use something like Handlebars instead.

The actual library itself is pretty simple:

/* global console,$ */
var behanceAPI = function() {
	var key;
	var baseURL = "http://www.behance.net/v2/";
	
	function setKey(k) {
		key = k;	
	}
	
	function getProjects(user, cb) {
		var url = baseURL + "users/" + user + "/projects?api_key=" + key + "&callback=";
		console.log(url);
		$.get(url, {}, function(res, code) {
			cb(res.projects);
		}, "JSONP");
	}
	
	return {
		setKey: setKey,
		getProjects: getProjects	
	};
	
}();

So, because of the limits Behance puts on API calls, I decided not to put this demo online. (And yes, I realize my own key is up there!) Instead, I've attached a zip of the project to this blog entry. Here is a screenshot of the result:

Not terribly exciting yet, I know. But - I'm thinking that in my next revision, I'm going to allow you to create a simple template, pass it to the library, and have the output handled for your automatically. My thinking is that many of the people who may use this API are creatives who may not have much JavaScript experience.

Download attached file


JavaScript library Integration

Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • mxGraph Usage in TypeScript Projects
  • Java and JavaScript Integration in OSGI
  • Freedom to Code on Low-Code Platforms
  • The Emergence of Cloud-Native Integration Patterns in Modern Enterprises

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: