我有一个使用 AS2/PHP 运行的应用程序。AS2 通过 $_POST 数据数组与 PHP 脚本通信,该数组包含 sessionkey、userID 等数据和一些数据库过滤(sql limit、order by 等)
该应用程序的 iOS 版本已计划推出,我正在尝试找出使用现有服务器端代码并仅重写图形的最佳方法。
问题是我需要大量数据,理想情况下应该通过 $_POST 数组将数据发送到 GET http 请求中(如果我不清楚,请随时向我提问)。
我读过这篇文章《理解 REST:动词、错误代码和身份验证》,这让我更好地理解了 REST 应该如何工作,但我需要将更多数据发送到服务器。
例如,假设我想检索项目集合,请求将类似于:
GET http://xxx/rest/item
Run Code Online (Sandbox Code Playgroud)
但是我如何告诉服务器我只想从集合中检索 X 个元素,甚至我想要哪种排序顺序?
感谢您之前的回答
编辑:@laurent,这里是收到的脚本 POST 参数的示例:
// COMMON PARAMETERS (each script)
$idPROF = Utils_Mv::getVariablePOST('idPROF');
$idVISITE = Utils_Mv::getVariablePOST('idVISITE');
$typeConnexion = Utils_Mv::getVariablePOST('typeConnexion');
$typeSupport = Utils_Mv::getVariablePOST('typeSupport');
$cleSession = Utils_Mv::getVariablePOST('cleSession');
$idCLIENT = Utils_Mv::getVariablePOST('idCLIENT');
$idCONTEXTE = Utils_Mv::getVariablePOST('idCONTEXTE');
// SCRIPT-SPECIFIC PARAMETERS
$idSUIVI = (int) Utils_Mv::getVariablePOST('idSUIVI');
$nbPrescription = (int) Utils_Mv::getVariablePOST('nbPrescription');
$indiceDebut = (int) Utils_Mv::getVariablePOST('indiceDebut');
$critereTri …Run Code Online (Sandbox Code Playgroud) 我想废弃一个网址:
1请求获取元素列表
每个结果1个请求以获取详细信息
在这里我有:
var request = require('request')
, cheerio = require('cheerio')
, async = require('async')
, format = require('util').format;
var baseurl = 'http://magiccards.info';
async.waterfall([
function (callback) {
request(baseurl + '/sitemap.html', function (err, response, body) {
var sets = [];
var $ = cheerio.load(body);
$('a[href$="/en.html"]').each(function () {
sets.push({"name": $(this).text(), "code":$(this).attr('href').match(/\/([^)]+)\//)[1], "path": $(this).attr('href'), "translations":[]});
});
callback(null, sets);
});
},
function (sets, callback) {
console.log(sets);
async.eachSeries(sets, function (set, callback) {
console.log('SET ' + set.code.toUpperCase());
request(baseurl + set.path, function (err, response, body) { …Run Code Online (Sandbox Code Playgroud) 这个答案说明这段代码:
$scope.gridOptions.onRegisterApi = function(gridApi){
$scope.gridApi = gridApi;
$scope.mySelectedRows=$scope.gridApi.selection.getSelectedRows();
}
Run Code Online (Sandbox Code Playgroud)
应该工作以获取所选行,但对我来说它总是返回[],以跟踪gridApi.selection.getSelectedRows()每次触发选择事件时我必须调用的所选行,这是正确的吗?
我想要实现的是自己的页脚跟踪网格选定行的数量,这是实现这一目标的正确方法吗?
我正在尝试在我的 python 应用程序中实现 peewee,并且在定义我的类时如下所示:
import datetime
import peewee as pw
import acme.core as acme
adapter = pw.MySQLDatabase(
acme.get_config(path='database.db'),
host=acme.get_config(path='database.host'),
port=int(acme.get_config(path='database.port', default=3306)),
user=acme.get_config(path='database.user'),
passwd=acme.get_config(path='database.password'))
class Model(pw.Model):
"""
The base model that will connect the database
"""
id = pw.PrimaryKeyField()
created_at = pw.DateTimeField()
updated_at = pw.DateTimeField(default=datetime.datetime.now)
class Meta:
database = adapter
class ServerModule(Model):
enabled = pw.BooleanField()
ipaddr = pw.IntegerField()
port = pw.IntegerField()
class Meta(Model.Meta):
db_table = 'module_server'
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Traceback (most recent call last):
File "db.py", line 25, in <module>
class ServerModule(Model):
File …Run Code Online (Sandbox Code Playgroud) 我很难弄清楚这是否可以用正则表达式实现。我有以下字符串(原始字符串更长,它是一个 json 字符串):
... "WorkstationName":"WS-8300E-007","IpAddress":"192.10.10.10" ...
Run Code Online (Sandbox Code Playgroud)
我想捕获IpAddress或者,如果 IpAddress 不存在,则WorkstationName
# IPADDR = 192.10.10.10
... "WorkstationName":"WS-8300E-007","IpAddress":"192.10.10.10" ...
# IPADDR = WS-8300E-007
... "WorkstationName":"WS-8300E-007","IpAddress":"-" ...
Run Code Online (Sandbox Code Playgroud)
我尝试了几种模式:
但没有成功,我需要在命名组中捕获模式,(?P<ipaddr>)以便其他软件可以处理输出。
我最终得到的最新正则表达式是:
(?:("WorkstationName":)(?=.*IpAddress":"-"))?(?(1)(?:"([^"]+)")?|.*IpAddress":"([^"]+")?)(?P<ipaddr>(?(2)\2|\3))
Run Code Online (Sandbox Code Playgroud)
所以,基本上,我这样做:
我遇到的困难是使用命名组,我已经成功捕获了 2 组中的所有内容,但我绝对需要根据字符串在同一组中。
我不能使用 JSON 解析器
我在php 5.3+中读过一些关于命名空间和自动加载的帖子,但是仍然没有成功创建一个工作:x也许你们中的一些人知道我的代码出了什么问题?谢谢你以前.
Autoloader.php 类
<?php
namespace my;
class AutoLoader {
private $aExt;
private $sPath;
protected static $instance;
public static function getInstance() {
if(!self::$instance instanceof self ) {
self::$instance = new self();
}
return self::$instance;
}
function __construct($sPath = __DIR__, $exts = 'php') {
// define path and extensions to include
$this->setPath($sPath);
$this->setExtensions($exts);
}
public function getPath() {
return $this->sPath;
}
public function setPath($path){
$this->sPath = $path;
}
public function removePath() {
unset ($this->sPath);
}
public function addExtension($ext) {
// prepends …Run Code Online (Sandbox Code Playgroud) 在Javascript中,是否可以在后台运行函数?
我在angularJS应用程序中使用pdfmake工具生成pdf,但pdf生成很长(3-4秒),在此期间,ui完全冻结.
我想运行后台任务并强制执行pdf下载而不冻结用户ui,是否可能?
我在这里运行pdfmake(pdfmake并且_是自定义工厂):
'use strict';
angular.module('App')
.service('CatalogPdfService', ['pdfmake', '_', '$q', '$filter',
function (pdfmake, _, $q, $filter) {
var $translate = $filter('translate');
var listDate = new Date();
return {
download: download
};
function download(data) {
listDate = _.first(data).publishedOn;
console.log('start download');
var deferred = $q.defer();
var filename = $translate('APP.EXPORT.pdf.catalog.title', {date: $filter('amDateFormat')(listDate, 'DDMMYYYY')}) + '.pdf';
create(data).download(filename, function () {
console.log('end download');
deferred.resolve();
});
return deferred.promise;
}
function create(data) {
// group data by category
var dataByCategory …Run Code Online (Sandbox Code Playgroud) 是否有可能在PHP中比较thoses字符串:
Æther == AEther == Aether
Run Code Online (Sandbox Code Playgroud)
我希望从这种等价中得到积极的结果
我实际上尝试了很多事情,但没有取得真正的成功:
使用strtr将Æ和任何特殊字符替换为Ae(性能不佳,我宁愿保持字符串不变)
使用strcmp/strcasecmp,这解决了上限问题,但我仍然遇到所有UTF-8字符的问题
我想要实现的是解析从json检索到的元素列表并与其他一些json文件匹配,有些可以拼写不同(utf8或非utf8,大写等),所以,现在,唯一的方法我发现这样做是为了制作第三个这样的json:
{
"match": {
"name": "Unravel the \u00c6ther"
},
"replace": {
"name": "Unravel the aether"
}
Run Code Online (Sandbox Code Playgroud)
我用corect替换了基本字符串,但我想找到一种自动化过程的方法.