123RF Value Added Reseller – Checking Available Download Credits (Part 4 of 5)

123RF's Value Added Reseller Guide

Download credits are a necessary component of the entire Value Added Reseller program. When you sign up as a Value Added Reseller, you will have an assigned Customer ID. Any future reloads of purchased download credits will be associated with this Customer ID.

This segment deals with how we can use the 123RF API to check for available download credits in the assigned Customer ID.

About the getCreditCount API Method

123RF’s getCreditCount API method (123rf.customer.getCreditCount) requires the following arguments:

Arguments Description
apikey This APIkey is the commercial API key that you will be using to interface with 123RF
accesskey This key is only given to the commercial key holder
custid The customer ID is unique to you – this information will be given once you have signed up for the Value Added Reseller Program

Please note that in order for this method to work you need to “sign” it with the “APIsign” method (API signature (apisign)). We’ll go through this tutorial so that you can understand the API sign better and how it works in the big scheme of things.

Step 1: Compiling the necessary information

In this example, we will be using 3 pieces of information:

  1. Commercial API Key = b59e8b113748a3a0676045573eb667b2
    Available from http://www.123rf.com/api/key/list.php – look under Commercial Key section
  2. Secret Key = 8b5be6e0fad722
    Available from http://www.123rf.com/api/key/list.php – look under Commercial Key section
  3. Access Key = 44dacbef
    Available from http://www.123rf.com/api/key/list.php, click on the “Additional Info” link for the Commercial Key above.
  4. Customer ID = b55310528064e5e
    Customer ID is given to you once you join the VAR program.

Now that we have gotten the necessary information, we can proceed to create the API sign which is another required argument to be sent to the API call.

Step 2: Generating the MD5 Hash for API Sign

In order to create the MD5 hash for API sign, we need to first determine the required arguments that have to be passed to the API call. This is the example that the documentation has given us:
http://api.123rf.com/rest/?method=123rf.customer.getCreditCount&apikey=32c31c104fd62a1092c4af8f922e5dd5&custid=46934e5f53ec7&accesskey=r7yu4hy65et4&apisign=y643y7u865wghr6t4y6et68ujd564j88

It is then evident that we require :

  1. apikey
  2. custid
  3. accesskey
  4. apisign

Next, according to the APIsign documentation, we need to create the API signatures (apisigns) by using a combination of the secretkey and other arguments needed by API call in alphabetical order, argument name followed by the value.

The structure of the API signature looks like this: <secretKey>accesskey<accesskey>apikey<apikey>custid<custid>method<method>
Plugging in the variables gives us this string:

 8b5be6e0fad722accesskey44dacbefapikeyb59e8b113748a3a0676045573eb667b2custidb55310528064e5emethod123rf.customer.getCreditCount

Next, we need to pass this through a MD5 hash (using MySQL or PHP) to yield:
dc94d733c8fe00f00e0944c22ebc4958

Step 3: Constructing the URL that will be passed to the API method

Now, we will construct the URL that the API call is expecting, and append the API sign at the back. We then have:

http://api.123rf.com/rest/?method=123rf.customer.getCreditCount&accesskey=44dacbef&apikey=b59e8b113748a3a0676045573eb667b2&custid=b55310528064e5e&apisign=dc94d733c8fe00f00e0944c22ebc4958

You may click on the link above to see that the XML returned looks something like this:

123RF checkCredits Successful

Therefore, if you have enough credits, you may now download the required content from within your application, which we will find out in the installment of the tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *