App.Site.Index
默认接口服务

接口地址:http://demo.phalapi.net/?s=App.Site.Index

接口文档

接口描述: 默认接口服务,当未指定接口服务时执行此接口服务

接口参数

参数名字类型是否必须默认值其他说明
username字符串可选PhalApi用户名

参数名字

返回结果类型说明
title字符串标题
content字符串内容
version字符串版本,格式:X.X.X
time整型当前时间戳

错误列表

错误状态码错误描述信息
400非法请求,参数传递错误
404表示接口服务不存在
500表示服务端内部错误

在线测试   

参数是否必须
service 必须
username 可选

客户端请求示例

{
    "ret": 200,
    "data": {
        "title": "Hello PhalApi",
        "version": "2.7.0",
        "time": 1558489902
    },
    "msg": ""
}
curl http://demo.phalapi.net/?s=App.Site.Index&username=PhalApi
{"ret":200,"data":{"title":"Hello PhalApi","version":"2.13.1","time":1585536376},"msg":""}

$.ajax({
      url: "http://demo.phalapi.net/",
      data: {s: "App.Site.Index", username: "PhalApi"},
      dataType: 'json',
      success: function (response, status, xhr) {
          console.log(response);
      }
});
<?php
require_once dirname(__FILE__) . '/PhalApiClient.php';

$client = PhalApiClient::create()
    ->withHost('http://demo.phalapi.net/');$rs = $client->reset()
    ->withService('App.Site.Index')
    ->withParams('username', 'PhalApi')
    ->withTimeout(3000)
    ->request();

// ret状态码,200表示成功
var_dump($rs->getRet());
// 业务数据
var_dump($rs->getData());
// 提示信息
var_dump($rs->getMsg());
#-*- coding:utf-8 -*-
import PhalApiClient

result = PhalApiClient.PhalApiClient('http://demo.phalapi.net/', 'App.Site.Indexx', {'username': 'PhalApi'}, 3)
//FullscreenActivity.java
import net.phalapi.sdk.*;    /**
     * 网络操作相关的子线程
     */  
    Runnable networkTask = new Runnable() {  
      
        @Override  
        public void run() {  
            // TODO  
            // 在这里进行 http request.网络请求相关操作  
            
        	PhalApiClient client = PhalApiClient.create()
	       			    .withHost("http://demo.phalapi.net/");
	       	
	       	PhalApiClientResponse response = client
	       			    .withService("App.Site.Index")
	       			    .withParams("username", "dogstar")
	       			    .withTimeout(3000)
	       			    .request();

	   		String content = "";
	   		content += "ret=" + response.getRet() + "\n";
	   		if (response.getRet() == 200) {
				try {
					JSONObject data = new JSONObject(response.getData());
					content += "data.title=" + data.getString("title") + "\n";
					content += "data.content=" + data.getString("content") + "\n";
					content += "data.version=" + data.getString("version") + "\n";
				} catch (JSONException ex) {
					  
				}
	   		}
			content += "msg=" + response.getMsg() + "\n";
			
			Log.v("[PhalApiClientResponse]", content);
            
            
            Message msg = new Message();  
            Bundle data = new Bundle();  
            data.putString("value", content);  
            msg.setData(data);  
            handler.sendMessage(msg);  
        }  
    }; 
PhalApiClientResponse response = PhalApiClient.create()
  .withHost("http://demo.phalapi.net/")
  .withService("Default.Index")
  .withparamsList("name", "dogstar")
  .withTimeout(3000)
  .request();

Log.v("response ret", response.ret + "");
Log.v("response data", response.data);
Log.v("response msg", response.msg);
package main

import (
	"./PhalApiClient"
	"fmt"
	"net/url"
)
func main() {
	rs, err := PhalApiClient.NewRequest().
		WithHost(`http://demo.phalapi.net/`).
		WithService("App.Site.Index").
		WithParams(url.Values{}).
		Get()
	if err != nil {
		fmt.Println(err.Error())
	} else {
		fmt.Println("code------------------------", rs.Code)
		fmt.Println("data------------------------", rs.Data)
		fmt.Println("msg------------------------", rs.Msg)
	}
}
#import "AFNPhalApiClient.h"// 待POST的参数
NSDictionary *params = @{@"demo_key_1": @"your_key", @"demo_key_2": @"1.0"};

// 使用AFNPhalApiClient
[[[[[AFNPhalApiClient sharedClient] withHost:@"http://demo.phalapi.net/"] withService:@"App.Site.Index"] withParams:params] requestWithFormDataBlock:^(id formData) {
	// 如需上传文件(图片等),请参照如下格式
    [formData appendPartWithFileData:UIImageJPEGRepresentation([UIImage imageNamed:@"head.JPG"], 1) name:@"file" fileName:@"image.jpg" mimeType:@"image/jpeg"];
} completeBlock:^(id resultObject) {
    PALog(@"resultObject: %@", resultObject);
} failureBlock:^(NSError *error) {
    PALog(@"error: %@", error);
}];

// 打印url查看
PALog(@"total url: %@", [[AFNPhalApiClient sharedClient] printTotalUrlStr]);
温馨提示: 此接口文档根据接口代码和注释实时自动生成,帮助文档请见PhalApi 2.x 开发文档