API Document
本文档将介绍如何使用 jsObf API 来对JS代码进行加密。该接口提供了两种JS代码输入方式。
普通接口
POST https://www.jsobf.com/v1/obf
请求参数
  
    
      | 参数名称 | 必选 | 类型 | 描述 | 
  
  
    
      | code | 是 | String | JS代码 | 
    
      | level | 否 | Int | 复杂度 | 
    
      | format | 否 | String | 返回数据格式,支持 json 和 xml,默认为json | 
    
      | key | 是 | String | 密钥(登录后在用户中心获取) | 
  
返回数据参数
  
    
      | 参数名称 | 类型 | 描述 | 
  
  
    
      | code | String | JS代码 | 
    
      | level | int | 复杂度 | 
  
代码示例
<?php
$data['content'] = file_get_contents('https://www.jsobf.com/examples/purejs.txt');
$data['format'] = "json";
$data['key']    = "your key";
$opts = array(
    'http' =>
        array(
            'method'  => 'POST',
            'content' => http_build_query($data)
        )
);
$ctx = stream_context_create($opts);
$ret = file_get_contents('https://www.jsobf.com/v1/obf', false, $ctx);
var_dump($ret);
?>
文件接口
POST https://www.jsobf.com/v1/obffile
请求参数
  
    
      | 参数名称 | 必选 | 类型 | 描述 | 
  
  
    
      | file | 是 | Binary | JS文件 | 
    
      | level | 否 | Int | 复杂度 | 
    
      | format | 否 | String | 返回数据格式,支持 json 和 xml,默认为json | 
    
      | key | 是 | String | 密钥(登录后在用户中心获取) | 
  
返回数据参数
  
    
      | 参数名称 | 类型 | 描述 | 
  
  
    
      | code | String | JS代码 | 
    
      | level | int | 复杂度 | 
  
代码示例
<?php
$url = 'https://www.jsobf.com/v1/obffile';
$cfile = curl_file_create(realpath('filename.js'), 'plain/javascript','html');
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt(
    $curl,
    CURLOPT_POSTFIELDS,
    array(
      'file' => $cfile,
      'xssfilter' => true,
      'format' => 'json',
      'key' => 'your key'
    )
);
$ret = curl_exec($curl);
curl_close($curl);
var_dump($ret);
?>