分享"狼用"API一個

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 "$!";
while( read( FILE, $buf, 60*57 ) ) { $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 );
				
时间: 2024-08-07 04:31:45

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

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

注:这里的服务是指Windows 服务. 市面上常见的安装一个服务的方法大概有这么几种: 用Process类调用sc.exe.Installutil.exe等外部工具进行安装.极不推荐,须知创建一个进程开销不小,并且依赖外部工具有损程序健壮性 使用TransactedInstaller和AssemblyInstaller安装类进行安装.不推荐,既然都用托管方法,何不用更好的方法呢 用ManagedInstallerClass.InstallHelper进行安装.这个我认为是托管方法中首选的方法,

Web API 基于ASP.NET Identity的Basic Authentication

今天给大家分享在Web API下,如何利用ASP.NET Identity实现基本认证(Basic Authentication),在博客园子搜索了一圈Web API的基本认证,基本都是做的Forms认证,很少有Claims认证(声明式认证),而我们在用ASP.NET Identity实现登录,认证,授权的时候采用的是Claims认证. 在Web API2.0中认证接口为IAuthenticationFilter,我们只需实现该接口就行.创建BasicAuthenticationAttribut

Android如何使用API

本文针对Android开发如何使用API文档进行一些经验分享. 1.为什么需要掌握API的使用. 也许你需要完成一个功能时很多时候你在网上google一番,因为很可能找到有用的代码片段,甚至不用关心具体实现的原理就可以直接拿来用.你可能遇到过搜出来的结果不太令人满意,尤其是你需要完成的功能比较新颖,demo比较少. 这个时候开发最好最快的途径就是用好API,掌握好API的使用也是程序开发的必修课. 2.API的重要性. 其实很多初学者都没有查|API的习惯,原因很简单:API仅仅是对一些类库.方

Android 怎样使用API

本文针对Android开发如何使用API文档进行一些经验分享. 1.为什么需要掌握API的使用. 也许你需要完成一个功能时很多时候你在网上google一番,因为很可能找到有用的代码片段,甚至不用关心具体实现的原理就可以直接拿来用.你可能遇到过搜出来的结果不太令人满意,尤其是你需要完成的功能比较新颖,demo比较少. 这个时候开发最好最快的途径就是用好API,掌握好API的使用也是程序开发的必修课. 2.API的重要性. 其实很多初学者都没有查|API的习惯,原因很简单:API仅仅是对一些类库.方

Web Api 2 认证与授权 2

HTTP Message Handler 在 Web Api 2 认证与授权 中讲解了几种实现机制,本篇就详细讲解 Message Handler 的实现方式 关于 Message Handler 在 request 到 response 过程所处于的位置,可以参考这里 HTTP Message Handlers Authentication Message Handler 先看一段实现的代码,然后再做讲解,完整代码可以在 Github 上参考,WebApi2.Authentication 1

握手API网关(7)开发指南-API参考

一.简介 用户可以使用开发指南介绍的 API 对 API 网关服务进行相关操作. 术语表 术语 全称 中文 说明 Region   地域 用户开放API,需选择API在API网关的部署地域,建议选择与后端服务相同的Region. API   应用程序编程接口 用户开放API,在API网关录入API,以提供接口的方式对外提供服务或者数据. Group API Group API分组 一组API. 用户开放API,首先需要创建API分组 每个API分组拥有一个二级域名,两个Stage 用户需要将已经

最美应用API接口分析

最美应用API接口分析html, body {overflow-x: initial !important;}.CodeMirror { height: auto; } .CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; } .CodeMirror-lines { padding: 4px 0px; } .CodeMirror pre { padding: 0px 4px; } .CodeMirror-scrollbar-fill

使用node.js进行API自动化回归测试

概述 传统的QA自动化测试通常是基于GUI的,比如使用Selenium,模拟用户在界面上操作.但GUI测试的开发.维护成本和运行的稳定性一直是测试界的老大难问题.投入大量的人力物力开发.维护.运行,却得不到相应的回报,令许多同行头痛不已.不过端对端(end to end)测试确实是QA/测试团队的重点工作之一,是绕不过的坎,怎么破?今天就分享一下基于API(HTTP层面)的自动化测试,姑且叫它“半端对端 (semi end to end)”吧.其实我认为它已经接近95%端对端了,为什么这样说?

Android中文API——PopupWindow

此文上半部分为本人翻译API文档,下半部分转自网友分享资料. API文档 继承树: java.lang.Object ? android.widget.PopupWindow 概述: popupWindow,顾名思义,用作在当前Activity前弹出一个界面,这个界面可以用来展示任何类型的View. 公共的构造器: PopupWindow() PopupWindow(Context context) PopupWindow(Context context, AttributeSet attrs)