Created
          April 27, 2015 08:00 
        
      - 
      
- 
        Save jasonsarino/72bd1cda78c5f6338cd8 to your computer and use it in GitHub Desktop. 
    Pass Form Data into other server using curl api.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class api{ | |
| public function processAPI($module, $jsonData = ''){ | |
| $tokenID = "C0QDeJLRiFWY8W0XN0fiO3J05iVcQWW66L6bxSiZLe60vk07WL8a6048e92W4ZlU5m0NRMiJQLV3F50o"; | |
| $baseapi = "http://domain.com/apit/api.php"; | |
| $ipAddress = "192.185.123.25"; | |
| $fields_string = ""; | |
| $dataArray = array( | |
| 'tokenID' => $tokenID, // tokenID | |
| 'module' => $module, // module color, furniture, home, etc.. | |
| 'ipAddress' => $ipAddress, // ip address | |
| 'jsonData' => $jsonData // (optional) data from sell your boat, contact page etc.. | |
| ); | |
| //$url = $baseapi.'?'.http_build_query($dataArray); | |
| foreach($dataArray as $key=>$value) { $fields_string .= urlencode($key).'='.urlencode($value).'&'; } | |
| rtrim($fields_string, '&'); | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
| curl_setopt($ch, CURLOPT_URL, $baseapi); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
| curl_setopt($ch, CURLOPT_POST, true); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); | |
| $result = curl_exec($ch); | |
| return $result; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment