小编kit*_*sei的帖子

向剩余 GET 请求添加参数

我有一个使用 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)

rest post get

4
推荐指数
1
解决办法
2万
查看次数

nodejs async嵌套调用

我想废弃一个网址:

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)

javascript asynchronous node.js

4
推荐指数
1
解决办法
6704
查看次数

Angular ui-grid 3.0获取选定的行

这个答案说明这段代码:

$scope.gridOptions.onRegisterApi = function(gridApi){
  $scope.gridApi = gridApi;
  $scope.mySelectedRows=$scope.gridApi.selection.getSelectedRows();
}
Run Code Online (Sandbox Code Playgroud)

应该工作以获取所选行,但对我来说它总是返回[],以跟踪gridApi.selection.getSelectedRows()每次触发选择事件时我必须调用的所选行,这是正确的吗?

我想要实现的是自己的页脚跟踪网格选定行的数量,这是实现这一目标的正确方法吗?

javascript angularjs angular-ui-grid

4
推荐指数
2
解决办法
2万
查看次数

元子类继承

我正在尝试在我的 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)

python peewee

3
推荐指数
1
解决办法
980
查看次数

使用正则表达式捕获一个或其他组

我很难弄清楚这是否可以用正则表达式实现。我有以下字符串(原始字符串更长,它是一个 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)

所以,基本上,我这样做:

  • 检查是否在“WorkstationName”后面,在某个时候是一个无效的 ip(“-”)
  • 如果是,请在\1 中捕获工作站名称
  • 如果组\1存在,则捕获工作站名称
  • 否则捕获ip地址

我遇到的困难是使用命名组,我已经成功捕获了 2 组中的所有内容,但我绝对需要根据字符串在同一组中。

我不能使用 JSON 解析器

regex

3
推荐指数
1
解决办法
1166
查看次数

php名称空间和自动加载

我在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)

php namespaces autoload

1
推荐指数
1
解决办法
2991
查看次数

在javascript中运行"后台任务"

在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)

javascript angularjs pdfmake

1
推荐指数
1
解决办法
5368
查看次数

PHP比较字符串与重音和没有重音

是否有可能在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替换了基本字符串,但我想找到一种自动化过程的方法.

php string utf-8

0
推荐指数
1
解决办法
1516
查看次数