我在php中构建自己的rest api进行练习.我可以评估发送到我的api的http代码(post,put,delete,get).但是当我发出我的回复时,我真的只是打印出一个json.例如,我在我的api中建立了一个响应
public function actionTest()
{
$rtn=array("id":"3","name":"John");
print json_encode($rtn);
}
Run Code Online (Sandbox Code Playgroud)
无论如何我都没有操纵标题.从阅读stackoverflow,我知道我应该返回http响应代码以匹配我的api结果.如何构建我的api并返回响应代码.我只是不明白我是怎么做到的,因为现在我只是打印出一个json.
我不是要问哪些代码要返回.我只是想知道如何返回代码.
Polymer 1.0:如何在纸张下拉菜单中获取所选项目的值?
我正在使用iron-ajax提交一些信息,而且我不能从纸张下拉菜单中获得价值(我不想要标签).我的纸张下拉菜单的ID是'mymenu'.我试过这些:
this.$.mymenu.selectedItem.value
Run Code Online (Sandbox Code Playgroud) 这是我的代码(现在“应用程序”只是一些虚拟页面)
import 'dart:async';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:flutter/foundation.dart';
// ************** Begin Auth
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn _googleSignIn = new GoogleSignIn();
Future<FirebaseUser> signInWithGoogle() async {
// Attempt to get the currently authenticated user
GoogleSignInAccount currentUser = _googleSignIn.currentUser;
if (currentUser == null) {
// Attempt to sign in without user interaction
currentUser = await …
Run Code Online (Sandbox Code Playgroud) 我在Mac OS X 10.9.4上
我可以从命令行成功运行此命令以生成图像或google.com
wkhtmltoimage http://www.google.com /Users/me/Sites/google.jpg
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用php命令从我的网站内执行相同的命令时
$cmd='wkhtmltoimage http://www.google.com /Users/me/Sites/google.jpg';
shell_exec($cmd);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
sh: wkhtmltoimage: command not found
Run Code Online (Sandbox Code Playgroud)
这是许可问题吗?如果是这样我怎么能让它工作?
====
我设置了像@Mureinik建议的完整路径,我现在取得了一些进展,我得到的错误信息是
Loading page (1/2)
[> ] 0%
[======> ] 10%
[=============> ] 23%
[==================> ] 31%
[===================> ] 33%
[========================> ] 41%
[=====================================> ] 62%
[=======================================> ] 65%
[========================================> ] 67%
[=========================================> ] 69%
[==========================================> ] 71%
[==============================================> ] 78%
[==================================================> ] 84%
[===================================================> ] 86%
[============================================================] 100%
Rendering (2/2)
[> ] 0%
[===============> ] 25%
Error: Could …
Run Code Online (Sandbox Code Playgroud) 我有一个测试数组,我从iron-ajax中检索大约1000个项目.我将返回数组设置为我的自定义聚合物元素的people属性.铁列表显示前20个结果,但是当我向下滚动时,其余的结果都没有被加载.
<link rel="import" href="/bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="/bower_components/iron-list/iron-list.html">
<link rel="import" href="/bower_components/iron-flex-layout/classes/iron-flex-layout.html">
<dom-module id="people-list">
<template>
<iron-list items="[[people]]" as="item" class="flex">
<template>
<div style="background-color:white; min-height:50px;">[[item.city]]</div>
</template>
</iron-list>
<iron-ajax
auto
id="ajaxPeopleList"
method="POST"
url="/people/list"
handle-as="json"
last-response="{{people}}">
</iron-ajax>
</template>
<script>
Polymer({
is: 'people-list',
properties: {
people: {
type: Array
}
}
});
</script>
</dom-module>
Run Code Online (Sandbox Code Playgroud)
我认为它可能与屏幕/铁列表元素的高度有关,但我卡住了,不知道如何继续.
如果我设置铁列表元素的高度(以像素为单位),我可以加载所有项目.但我只是想让它适合屏幕.文档看起来你可以使用iron-flex布局并使用类flex,这是我在我的示例代码中尝试做的,但它没有任何效果.
我正在使用Polymer 2.0.我有一个
<paper-input type="file" id"myFile"></paper-input>
Run Code Online (Sandbox Code Playgroud)
一旦我选择了一个文件,我想使用Polymer(javascript)来获取文件的引用和详细信息.以前我用过
this.$.myFile.inputElement.files[0];
Run Code Online (Sandbox Code Playgroud)
但这似乎现在不起作用,它说未定义.请帮我看一下这个文件.这是一个jsbin:
这是我的骨干代码
var UserModel=Backbone.Model.extend({
url: 'http://api.myapi.com/user'
});
var user=new UserModel();
user.set({id:1});
user.fetch();
console.log(user.get('screenname'));
Run Code Online (Sandbox Code Playgroud)
这将返回整个用户集合,而不是id为1的用户.当我将url更改为
url: 'http://api.myapi.com/user/1'
Run Code Online (Sandbox Code Playgroud)
我找回了我想要的用户.我为什么不能获得"用户1"的记录user.set({id:1});
注意 - 我的api位于不同的域,这就是我在'url'属性中拥有整个url的原因.请帮助,我准备放弃骨干.
polymer ×3
api ×2
php ×2
rest ×2
ajax ×1
backbone.js ×1
command-line ×1
fetch ×1
file ×1
firebase ×1
flutter ×1
http-headers ×1
input ×1
list ×1
selected ×1
shell ×1
wkhtmltopdf ×1