[PHP] 基于php的APK加密api调用代码实例 →→→→→进入此内容的聊天室

来自 , 2020-01-26, 写在 PHP, 查看 177 次.
URL http://www.code666.cn/view/69f268fb
  1. <!--?php
  2. // +----------------------------------------------------------------------
  3. // | JuhePHP [ NO ZUO NO DIE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2010-2015 http://juhe.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: Juhedata <info@juhe.cn-->
  8. // +----------------------------------------------------------------------
  9.  
  10. //----------------------------------
  11. // APK加密调用示例代码 - 聚合数据
  12. // 在线接口文档:http://www.juhe.cn/docs/76
  13. //----------------------------------
  14.  
  15. header('Content-type:text/html;charset=utf-8');
  16.  
  17.  
  18. //配置您申请的appkey
  19. $appkey = "*********************";
  20.  
  21.  
  22.  
  23.  
  24. //************1.①根据url上传待加密的apk************
  25. $url = "http://op.juhe.cn/ijiami/upload";
  26. $params = array(
  27.       "apkurl" => "",//需要进行加密的APK下载URL地址
  28.       "key" => $appkey,//应用APPKEY(应用详细页查询)
  29.       "dtype" => "",//返回数据的格式,xml或json,默认json
  30. );
  31. $paramstring = http_build_query($params);
  32. $content = juhecurl($url,$paramstring);
  33. $result = json_decode($content,true);
  34. if($result){
  35.     if($result['error_code']=='0'){
  36.         print_r($result);
  37.     }else{
  38.         echo $result['error_code'].":".$result['reason'];
  39.     }
  40. }else{
  41.     echo "请求失败";
  42. }
  43. //**************************************************
  44.  
  45.  
  46.  
  47.  
  48. //************2.②提交加密应用加密************
  49. $url = "http://op.juhe.cn/ijiami/encrypt";
  50. $params = array(
  51.       "appid" => "",//步骤①返回的appid
  52.       "key" => $appkey,//应用APPKEY(应用详细页查询)
  53.       "dtype" => "",//返回数据的格式,xml或json,默认json
  54. );
  55. $paramstring = http_build_query($params);
  56. $content = juhecurl($url,$paramstring);
  57. $result = json_decode($content,true);
  58. if($result){
  59.     if($result['error_code']=='0'){
  60.         print_r($result);
  61.     }else{
  62.         echo $result['error_code'].":".$result['reason'];
  63.     }
  64. }else{
  65.     echo "请求失败";
  66. }
  67. //**************************************************
  68.  
  69.  
  70.  
  71.  
  72. //************3.③查询加密结果************
  73. $url = "http://op.juhe.cn/ijiami/result";
  74. $params = array(
  75.       "appid" => "",//步骤②返回的appid
  76.       "key" => $appkey,//应用APPKEY(应用详细页查询)
  77.       "dtype" => "",//返回数据的格式,xml或json,默认json
  78. );
  79. $paramstring = http_build_query($params);
  80. $content = juhecurl($url,$paramstring);
  81. $result = json_decode($content,true);
  82. if($result){
  83.     if($result['error_code']=='0'){
  84.         print_r($result);
  85.     }else{
  86.         echo $result['error_code'].":".$result['reason'];
  87.     }
  88. }else{
  89.     echo "请求失败";
  90. }
  91. //**************************************************
  92.  
  93.  
  94.  
  95.  
  96.  
  97. /**
  98.  * 请求接口返回内容
  99.  * @param  string $url [请求的URL地址]
  100.  * @param  string $params [请求的参数]
  101.  * @param  int $ipost [是否采用POST形式]
  102.  * @return  string
  103.  */
  104. function juhecurl($url,$params=false,$ispost=0){
  105.     $httpInfo = array();
  106.     $ch = curl_init();
  107.  
  108.     curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
  109.     curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );
  110.     curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
  111.     curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
  112.     curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
  113.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  114.     if( $ispost )
  115.     {
  116.         curl_setopt( $ch , CURLOPT_POST , true );
  117.         curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
  118.         curl_setopt( $ch , CURLOPT_URL , $url );
  119.     }
  120.     else
  121.     {
  122.         if($params){
  123.             curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
  124.         }else{
  125.             curl_setopt( $ch , CURLOPT_URL , $url);
  126.         }
  127.     }
  128.     $response = curl_exec( $ch );
  129.     if ($response === FALSE) {
  130.         //echo "cURL Error: " . curl_error($ch);
  131.         return false;
  132.     }
  133.     $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
  134.     $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
  135.     curl_close( $ch );
  136.     return $response;
  137. }

回复 "基于php的APK加密api调用代码实例"

这儿你可以回复上面这条便签

captcha