API

People that are interested in using our service for automated caching of their newly created .torrent files or caching massive amounts of older files, can do so by using one our APIs.
This page contains some documentation on the APIs but also some example code in different languages. If you have some code for any additional language we do not cover, please give us some working example code over e-mail.

All files will be cached at http://torcache.net/torrent/<infoHash>.torrent

Note: HEX values A-F must be in uppercase in torrent URL's

SOAP API

The SOAP API is probably the most easy to use in a modern scripting/programming language. The WSDL offers one simply function; cacheTorrent(). The function returns the info hash of the torrent on success, or a three digit error code if there was an error.
The SOAP WSDL is located at http://torcache.net/torcache.wsdl.

PHP

Below is example code in PHP to cache "my.torrent". You would need to compile PHP --with-soap.

 $client = new SoapClient( 'http://torcache.net/torcache.wsdl' );
        $infoHash = $client->cacheTorrent( base64_encode( file_get_contents( 'my.torrent' ) ) );

PERL

Perl code to cache "my.torrent". Requires SOAP::Lite (libsoap-lite-perl in debian)

#!/usr/bin/perl

use MIME::Base64 ();
use SOAP::Lite ();

open( FILE, 'my.torrent' ) or die "$!";
* ) ) { $tor .= MIME::Base64::encode( $buf ); }
close( FILE );

$infoHash = SOAP::Lite->service( 'http://torcache.net/torcache.wsdl' )->cacheTorrent( $tor );

print $infoHash;

HTTP POST

If you don't have support for SOAP there is a normal HTTP POST interface. Here we show some example code for that as well.

PHP

Below is example code to cache "my.torrent". This feature requires the pecl_http extension.


$files = array(
        array(
            'name' => 'torrent',            // Don't change
            'type' => 'application/x-bittorrent',
            'file' => 'my.torrent'            // Full path for file to upload
        )
    );

    $http_resp = http_post_fields( 'http://torcache.net/autoupload.php', array(), $files );
    $tmp = explode( "\r\n", $http_resp );
    $infoHash = substr( $tmp[count( $tmp ) - 1], 0, 40 );
    unset( $tmp, $http_resp, $files );
												

分享"狼用"API一個的更多相关文章

  1. 微信JS-SDK“分享信息设置”API及数字签名生成方法(NodeJS版本)

    原文:微信JS-SDK"分享信息设置"API及数字签名生成方法(NodeJS版本) 先上测试地址以示成功: 用微信打开下面地址测试 http://game.4gshu.com/de ...

  2. 【C#】分享基于Win32 API的服务操作类(解决ManagedInstallerClass.InstallHelper不能带参数安装的问题)

    注:这里的服务是指Windows 服务. ------------------201508250915更新------------------ 刚刚得知TransactedInstaller类是支持带 ...

  3. 【分享】DevDocs API Documentation

    http://devdocs.io/ 这是一份综合性的在线API列表,很全,方便查找.

  4. 分享一个开源免费、目前最好的API接口管理平台----eoLinker

    一.概况 eoLinker 是目前业内领先.国内最大的在线 API 接口管理平台,提供自动生成 API 文档.API 自动化测试.Mock 测试.团队协作等功能,旨在解决由于前后端分离导致的开发效率低 ...

  5. 微信WeixinJSBridge API(屏蔽右上角按钮等)

    [声明]:我这份纯属于备份,为了自己将来用起来方便: [相关链接]:http://www.2cto.com/weixin/201511/451592.html(好不好用完全看这个文档的作者了) [感谢 ...

  6. 腾讯云>>云通信>>TLS后台API在mac上JAVA DEMO搭建

    1.相关文档地址 2.相关demo代码 代码部分作了修改,使用了commons-io中的IOUtils.toString简化了io操作 public class Demo { public stati ...

  7. App Store有哪些原因会影响app应用上架呢?(分享)

    App Store对于应用上架的审核是非常严格的,很可能一个没有注意到的细节,或者一个你根本没想想到的原因就会导致你的应用上架失败.而排除这些无可避免的错误以外,还有一些导致应用上架失败的原因,非常常 ...

  8. iOS----友盟分享完善版本

    分享 详细集成 注意:1.线上集成文档的示例代码对应的是最新版本的SDK,如果你所用的SDK版本类名或者方法名与此文档不符合,请看随包里面的线下文档或者下载使用最新版本的SDK. 设置友盟appkey ...

  9. 【转】ASP.NET WEB API系列教程

    from: 西瓜小强 http://www.cnblogs.com/risk/category/406988.html ASP.NET Web API教程(六) 安全与身份认证 摘要: 在实际的项目应 ...

随机推荐

  1. bzoj 1854: [Scoi2010]游戏

    #include<cstdio> #include<iostream> #include<cstring> #define M 2000008 using name ...

  2. JavaScript去除数组中的重复性

    Array.prototype.unique = function () { var res = [], hash = {}; for (var i = 0, elem; (elem = this[i ...

  3. Android 移动缩放的ImageView

    今天介绍一下Android中怎么实现ImageView的缩放和移动,自定义TouchImageView. public class TouchImageView extends ImageView { ...

  4. 【转发】linux文件系统变为只读的修复

    详细解决方法:http://smartmontools.sourceforge.net/badblockhowto.html 相关问题,更换硬盘:http://blog.chinaunix.net/u ...

  5. IOS开发中--点击imageView上的Button没有任何反应

    点击imageView上的Button没有任何反应:    解决方法:设置图片的userInteractionEnabled为YES,使该imageView可以与用户进行交互

  6. 简单的两数之和再次乱入<< Add Two Numbers >>

    请看题目描述: You are given two linked lists representing two non-negative numbers. The digits are stored ...

  7. 重拾java系列一java基础(3)

    这一章主要复习下以前所接触的算法, (1)选择排序法:在要排序的一组数中,选出最小的一个数与第一个位置的数交换:然后在剩下的数当中再找最小的与第二个位置的数交换,如此循环到倒数第二个数和最后一个数比较 ...

  8. (转)JSON数据格式和js操作json总结

    原:http://niutuku.com/tech/javaScript/273643.shtml JSON数据格式和js操作json总结 来源:niutuku.com |         vince ...

  9. hdu 2090

    PS:输入麻烦...我还以为是输入一个就输出一个...后来看了大神的才知道....暴力破解了... 代码; #include "stdio.h" int main(){ ,a,b; ...

  10. 超级链接a+ confirm用法

    示例: <a href="DelServlet?action=${fuwa.id}" onClick="return confirm('你确定要删除?')" ...