Wednesday, February 19, 2014

how to register sub reseller httpapi curl php

2/19/2014


Signing Up a Sub-Reseller Account using the httpapi.com api. It requires POST HTTP Method. You can use following function to register sub reseller with api intergration. You need auth-userid and api-key or auth-password for that. Look at code for more.

<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/


function SIGNUP_RESELLER($data)
{
 // post all required data through via $_POST in $data
 $_data = $data;

 # API Url: for test=>https://test.httpapi.com , for live=>https://httpapi.com
 $api_url = 'https://test.httpapi.com'; 

 $auth_userid = ''; // reseller unique id
 $api_key = ''; // api-key or reseller password

 if(isset($auth_userid) && isset($api_key))
 {
  $handle = curl_init();
  curl_setopt($handle, CURLOPT_URL,$api_url.'/api/resellers/signup.xml');
  curl_setopt($handle, CURLOPT_POST, 1);
  curl_setopt($handle, CURLOPT_POSTFIELDS,
              'auth-userid='.$auth_userid.'&api-key='.$api_key.'&username='.urlencode($_data['username']).'&passwd='.urlencode($_data['passwd']).'&name='.urlencode($_data['name']).'&company='.urlencode($_data['company']).'&address-line-1='.urlencode($_data['address1']).'&city='.urlencode($_data['city']).'&state='.urlencode($_data['state']).'&country='.urlencode($_data['country']).'&zipcode='.urlencode($_data['zip']).'&phone-cc='.urlencode($_data['telnocc']).'&phone='.urlencode($_data['telno']).'&lang-pref='.$_data['langpref'].'&accounting-currency-symbol='.$_data['accountingcurrencysymbol'].'&selling-currency-symbol='.$_data['sellingcurrencysymbol']   );

  // receive server response ...
  curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  $server_output = curl_exec ($handle);
  curl_close ($handle);


  // echo $server_output;
  if( strpos($server_output,'AlreadyReseller') === FALSE)
  {
   echo "You're Almost Done. Your Sub-Reseller Account has been successfully registered.";
   return true;
  }
  else
  {
   echo "".$_data['username']." Already Reseller";
  }

 }

 return false;


}

?>
USAGE
<?php
/*
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/

 
    if($_SERVER["REQUEST_METHOD"] == "POST")
    {

       SIGNUP_RESELLER($_POST);
                              
    }
    else
    {
        $_POST = NULL;
    }

?>

helpful? Share this

The Editorial Team of 4everTutorials consists of a group of PHP Professionals.

1 comments:

Godson said...

nice post. whiich section of my website do i paste the codde.

 

© 2014 4everTutorials. All rights resevered.

Back To Top