Jump to content

How do I create a authentication key ?


citywide440

Recommended Posts

Im trying to work with a Companies API Program - I have never done any coding or used PHP before - Im currently stuck at how do I create the authentication code 

What program should I use ? How do i do it ? - I have all the info it requests Secret key, account id and image id but I have no ideal what to do with it. 

Im currently stuck and really need help with this. 

Below is exactly what is listed on there site - Thanks in Advance 

  Purchase

Once you have funded your API account you will be able to download full resolution un-watermarked images. Purchasing images requires an authentication key to be passed with each request. The authentication key is generated using the secret key provided and is a combination of the secret key, your account ID and the image ID the user is purchasing. The authentication key is the SHA-1 hash (40 character hexadecimal) of those three data elements.

// Example PHP code to generate auth_key for purchase request

$auth_key = sha1($secret_key . $account_id . $image_id);

The auth_key that is generated needs to be passed with the purchase request. To purchase an image, include the image ID, Size Code and the authentication key.

api.bigstockphoto.com/2/[account id]/purchase?image_id=[image id]&size_code=&auth_key=[auth_key]

If the purchase is approved, a download ID will be returned which can then be used to download the image file.

{"response_code":200,

"message":"success",

"data":{

"currency_amount":2.99,

"currency_code":"USD",

"download_id":724111049}

}

 
Link to comment
Share on other sites

There are a few ways to connect to an api. The most popular in API documentation being file_get_contents();

 

<?php
$response = file_get_contents("URL here");
echo "Response from the server was: ".$response;
?>
You could also use cURL if you would want to add more advanced options. But this should work as you only need json it seems.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.