Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hi i need help making my api php files

    hi i need help making my api files here the following code

    License Activation using the “POST” method
    Description: Request to validate a license key and also log/write the user’s data into the database. You have to use this method upon software activation so InstaMember can count or limit the usage properly.
    API End-Point: http://YOURDOMAIN.COM/!/instamember_api/license/{license_key}
    PHP Example:
    <?php
    $secret_key = ‘YOUR SECRET KEY’; $license_key = ‘LICENSE KEY HERE’;
    $md5_hash = md5($license_key . $secret_key);
    $api_url = “http://yourdomain.com/!/instamember_api/license/{$license_key}”;
    $hostname = @gethostbyaddr($_SERVER['SERVER_ADDR']); $data = array(
    'domain' => $_SERVER['HTTP_HOST'], 'userip' => $_SERVER['REMOTE_ADDR'],
    'servip' => ( $hostname ) ? $hostname : $_SERVER['SERVER_ADDR']
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $api_url);
    curl_setopt($ch, CURLOPT_USERPWD, "{$secret_key}:{$md5_hash}"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    $result = curl_exec($ch); $response = json_decode($result);
    If ( $response->status == ‘Success’ ) {
    // code to unlock software here…
    } else {
    // code handling error here…
    }
    License Validation using the “GET” method
    Description: Request to validate the license whether the license is still active or invalid (e.g. expired, inactive, suspended, etc). This method does not accept any type of data, and will not log any data into the database.
    API End-Point: http://YOURDOMAIN.COM/!/instamember_api/license/{license_key}
    PHP Example:
    <?php
    $secret_key = ‘YOUR SECRET KEY’; $license_key = ‘LICENSE KEY HERE’; $md5_hash = md5($license_key . $secret_key);
    $api_url = “http://yourdomain.com/!/instamember_api/license/{$license_key}”;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $api_url);
    curl_setopt($ch, CURLOPT_USERPWD, "{$secret_key}:{$md5_hash}"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    $response = json_decode($result);
    If ( $response->status == ‘Expired’ ) {
    // the license key is expired… do something here… } else if ( $response->status == ‘Suspended’ ) {
    // the license key has been suspended… do something here…
    } else {
    // do something here…
    }
    10
    Status Types
    Success – License key is active or valid
    Maxed – License key is active but has reached the maximum usage limit (returned only upon activation)
    Expired – License key has expired
    Inactive – License key is not active or disabled by admin Suspended – License key has been suspended by admin Unauthorized – Authentication request failed
    Error – Any type of errors
    Response Data Example (in JSON)
    License Active/Success:
    {
    "status":"Success", "message":"License key is active"
    }
    License Inactive:
    {
    "status":"Inactive",
    "message":"License key is inactive or disabled"
    }
    License Expired:
    {
    "status":"Expired",
    "message":"License key has been expired"
    }
    License Maxed:
    {
    "status":"Maxed",
    "message":"License key is active but has reached the maximum usage limit"
    }
    License Suspended:
    11
    {
    "status":"Suspended",
    "message":"License key has been suspended"
    }
    Authentication Failed:
    {
    "status":"Unauthorized", "message":"Authentication failed"
    }
    License key is empty:
    {
    "status":"Error", "message":"License key is empty"
    }
    License is not found in the database:
    {
    "status":"Error", "message":"Invalid license key"
    }
    No post data upon activation:
    {
    "status":"Error",
    "message":"Required fields are empty"
    }
    License Keys Management
    Simply login to your WordPress Dashboard, and navigate to “InstaMember -> Manage Licenses.” You can view license keys that has been generated along with the details, including the member data, associated product and also the usage log. You can also “deactivate” or “reactivate” or “delete” a license key from this page.

    please help me with this. the first person that have it done for me asap i will give you 100 commission on the product once we launch.

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    This should be posted in the medium or large projects forum (depending on the scope of what you're trying to do), where you can hire someone.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •