小编Jos*_*los的帖子

请求使用Android应用中使用的用于服务器Web的Google Places API KEY拒绝

我正在尝试从Android应用的Google商家信息API获取信息.为此,首先我在Google帐户中启用了此API.

在此输入图像描述

在此输入图像描述

其次,我已经为浏览器创建了一个API KEY.由于其他API,我已经有了一个API KEY服务器.

在此输入图像描述

所以,在我的代码中,我已经使用这两个密钥进行了测试,并且两者都得到了相同的结果!

{

"error_message":"此服务需要API密钥.",

"html_attributions":[],

"结果":[],

"状态": "REQUEST_DENIED"

}

我用来打电话的代码是......

        @Override
    protected String doInBackground(LocationService... ls) {
        JSONObject result = new JSONObject();
        URL url;
        HttpsURLConnection urlConnection;

        // Making HTTP request
        try {

            //Define connection
            url = new URL("https://maps.googleapis.com/maps/api/place/nearbysearch/json");
            urlConnection = (HttpsURLConnection)url.openConnection();

            urlConnection.setRequestMethod("POST");
            urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            urlConnection.setRequestProperty("charset", "utf-8");
            urlConnection.setRequestProperty("Accept", "application/json");
            urlConnection.setDoOutput(true);
            urlConnection.setDoInput(true);
            urlConnection.setUseCaches(false);

            //Send data
            String parameters = "?location=" + String.valueOf(ls[0].getLocation().getLatitude()) + "," + String.valueOf(ls[0].getLocation().getLongitude());
            parameters+="&radius=5000";
            parameters+="&types=restaurant|health|city_hall|gas_station|shopping_mall|grocery_or_supermarket";
            parameters+="&sensor=false";
            parameters+="&key=" + Constants.API_KEY_BROWSER_APPLICATIONS;
            byte[] postData = parameters.getBytes(Charset.forName("UTF-8"));
            int postDataLength = postData.length;
            urlConnection.setRequestProperty("Content-Length", …
Run Code Online (Sandbox Code Playgroud)

java android google-places-api

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

Android Studio 1.3 中模拟器的屏幕分辨率错误

我已经更新到 Android Studio 1.3,我正在尝试使用分辨率为 1080px x 1920px 的 Nexus 5 进行测试,当我启动模拟器时,图标太大,当我运行我的应用程序时,其横幅为 320x50 。该横幅几乎与屏幕一样宽!

这是没有运行任何应用程序的模拟器,您可以在屏幕上看到一个非常大的图标。

在此输入图像描述

这是一个应用程序的屏幕截图,其横幅测试尺寸为 320x50px

在此输入图像描述

如果我在自定义皮肤定义中选择“无皮肤”,它对我不起作用。在后面的图片中你可以看到它。

另一个例子,这是我在 Android Studio 到平板电脑 Nexus 7 中看到的和我希望看到的:

在此输入图像描述

这就是我在 Android 模拟器中对平板电脑 Nexus 7 的感受:它太大了。为什么会出现这种情况?

在此输入图像描述

screen-resolution android-emulator android-studio

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

如何将原始查询 (Sequelize) 的结果返回到 GraphQL

我是 GraphQL 和 Sequelize 的新手,但我开发了一个测试,可以使用 Sequalize 的函数进行查询并从 Graphiql 获取结果,但我有兴趣通过多个表的查询来进行更复杂的查询。

现在,这段代码可以正常工作:

架构.js

import {
    GraphQLObjectType,
    GraphQLNonNull,
    GraphQLID,
    GraphQLInt,
    GraphQLString,
    GraphQLFloat,
    GraphQLList,
    GraphQLSchema
} from "graphql";
import { DB } from "../db";
import {DateTime} from "../scalar/dateTime";
import {Player} from "./Player";
import {League} from "./League";
import {Group} from "./Group";
import {Season} from "./Season";

const Query = new GraphQLObjectType({
    name: "Query",
    description: "This is root query",
    fields: () => {
        return {
            players: {
                type: GraphQLList(Player),
                args: {
                    id: {
                        type: GraphQLID
                    }
                }, …
Run Code Online (Sandbox Code Playgroud)

mysql node.js sequelize.js graphql

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

Matplotlib:annotate() 缺少 1 个必需的位置参数:'self'

我是 matplotlib 的新手,我试图将文本设置为图中的一个点,但出现错误:

回溯(最近一次调用最后一次):文件“main.py”,第 239 行,在 main() 文件“main.py”,第 232 行,在主 p.show_graphic_ortg_drtg() 文件“/home/josecarlos/Workspace/python/ process/process.py",第 363 行,在 show_graphic_ortg_drtg Axes.Axes.annotate(xy=(df[0:1]["ortg"], df[0:1]["drtg"]), s="Hola ") TypeError: annotate() 缺少 1 个必需的位置参数:'self'

我的代码是:

import matplotlib.axes as Axes

Axes.Axes.annotate(xy=(df[0:1]["ortg"], df[0:1]["drtg"]), s="Message")
Run Code Online (Sandbox Code Playgroud)

df 是之前生成的 Pandas 的 DataFrame。

我究竟做错了什么?我正在遵循一些教程和文档,但没有发现错误。

python matplotlib

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

虚拟主机:存在时找不到 JavaScript 文件

我已经安装了 Ubuntu 14.04,并在“etc/apache2/sites-available”中创建了一个名为“canvas.local.conf”的虚拟主机

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName canvas.local
    DocumentRoot /var/www/canvas
    <Directory /var/www/canvas>
            Options Indexes FollowSymLinks
            AllowOverride All
            allow from all
    </Directory>
Run Code Online (Sandbox Code Playgroud)

我创建了一个包含以下内容的“index.html”文件:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Demo Canvas</title>
        <!--[if lte IE8]><script src = "./javascript/excanvas.js"></script><![endif]-->
        <style>
            #canvas{
                width: 640px;
                height: 400px;
                border: 1px solid #000000;
            }
        </style>
        <script src = "./javascript/jquery-1.11.1.min.js"></script>
        <script>
            $(function(){
                alert("Page loaded");
            });         
        </script>
    </head>
    <body>
        <div id = "canvas"></div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

在目录“javascript”中存在文件“excanvas.js”和“jquery-1.11.1.min.js”

因此,当我通过“ http://canvas.local ”访问页面时,我可以看到页面已加载,但服务器找不到文件“jquery-1.11.1.min.js”。而这个文件存在于目录中。

javascript apache virtualhost

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

如何在 Oracle 查询中将 CLOB 转换为 UTF8?

我有一个带有 CLOB 字段的查询,我想以 UTF8 格式返回她的值。例如,如果字段是 varchar,则下一个查询可以正常工作,但如果是 CLOB,则不会返回正确的 UTF8 字符串。

select convert(field, 'AL32UTF8', 'WE8ISO8859P15') from table;
Run Code Online (Sandbox Code Playgroud)

如何从查询中的 CLOB 返回 UTF8 字符串?

oracle clob utf-8

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

开玩笑:无法导入提取

我是 JEST 的新手。我正在尝试获取数据,但要做到这一点,我必须导入它。但是,我有这个错误:

Details:

/home/josecarlos/Workspace/BlueCode/server/node_modules/node-fetch/src/index.js:9
import http from 'node:http';
       ^^^^

SyntaxError: Unexpected identifier

  1 | import config from "dotenv";
> 2 | import fetch from "node-fetch";
    | ^
  3 |
  4 | config.config();
  5 |

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
  at Object.<anonymous> (com/functions.js:2:1)
Run Code Online (Sandbox Code Playgroud)

我的节点版本是:v11.15.0

这是我的依赖:

  "dependencies": {
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-graphql": "^0.12.0",
"graphql": "^16.0.1",
"helmet": "^4.6.0",
"morgan": "^1.10.0",
"node-fetch": "^3.1.0"
  },

  "devDependencies": {
    "@babel/cli": "^7.16.0",
    "@babel/core": "^7.16.0",
    "@babel/node": "^7.16.0",
    "@babel/preset-env": "^7.16.0",
    "jest": "^27.3.1",
    "jshint": "^2.13.1",
    "nodemon": "^2.0.14"
  }
Run Code Online (Sandbox Code Playgroud)

import node.js jestjs

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

PHP7.0:调用未定义的函数 utf8_encode()

我正在使用 PHP 7.0 进行开发,并且尝试使用函数 utf8_encode() 并且出现错误“调用未定义的函数 utf8_encode()”

我必须尝试使用​​ sudo apt-get install php7.0-xml 安装 php7.0-xml 模块,但出现此错误:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet …
Run Code Online (Sandbox Code Playgroud)

php php-7 ubuntu-16.04

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

R:条形图高度必须是向量或矩阵

我正在尝试使用分组条制作条形图,但出现此错误:

“高度”必须是向量或矩阵

我不知道为什么。我的代码是...

rebDef=sample(50:100,14,replace=F)
rebOf=sample(20:40, 14, replace=F)
rebTot=sample(70:140, 14, replace=F)
data=data.frame(rebDef,rebOf,rebTot)
v <- c("Equipo A", "Equipo B", "Equipo C", "Equipo D", "Equipo E", "Equipo F", "Equipo G", "Equipo H", "Equipo I", "Equipo J", "Equipo K", "Equipo M", "Equipo N", "Equipo O")
names <- data.frame(v)
rownames(data) <- names[, 1]

barplot(data, beside=T , legend.text=T, col=c("red" , "green", "blue"), ylim=c(0,140), ylab="height")
Run Code Online (Sandbox Code Playgroud)

我从数据中得到的 dput 是......

structure(list(rebDef = c(93L, 59L, 80L, 58L, 71L, 70L, 83L, 
77L, 99L, 52L, 84L, 98L, 100L, 86L), rebOf = c(20L, …
Run Code Online (Sandbox Code Playgroud)

r bar-chart

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

Angular组件不呈现html,显示html路由

我为Angular创建了一个新组件,但我看不到渲染的html.而不是渲染的HTML,我有通往HTML的路径.

这些是我的文件夹结构:

在此输入图像描述

这是我创建的名为server.component.ts的组件:

import { Component } from '@angular/core';

@Component({
    selector: 'app-server',
    template: './server.component.html'
})
export class ServerComponent {

}
Run Code Online (Sandbox Code Playgroud)

这是组件的html,server.component.html:

<p>Este es mi nuevo componente!!!</p>
Run Code Online (Sandbox Code Playgroud)

app.component.html中我包含了我的组件的标记:

<div>
    <input type = "text" [(ngModel)] = "message" />
    <p>{{message}}</p>
    <hr>
    *<app-server></app-server>*
</div>
Run Code Online (Sandbox Code Playgroud)

这是我的app.module.ts代码,我导入ServerComponent以便以后使用它:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';


import { AppComponent } from './app.component';
import { ServerComponent } from './server/server.component';

@NgModule({ …
Run Code Online (Sandbox Code Playgroud)

components angular

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

Javascript:json对象数组的reduce函数不返回值的相加

我有这个包含这些数据的 json 对象数组:

      let data = [
    {"id_player_team" : 1, "name" : "Jose", "t2p_conv": 3, "t3p_conv": 5},
    {"id_player_team" : 2, "name" : "Jesus", "t2p_conv": 2, "t3p_conv": 1},
    {"id_player_team" : 3, "name" : "Maria", "t2p_conv": 3, "t3p_conv": 0},
    {"id_player_team" : 4, "name" : "Irene", "t2p_conv": 4, "t3p_conv": 2},
    {"id_player_team" : 5, "name" : "Carmen", "t2p_conv": 1, "t3p_conv": 2},
  ];
Run Code Online (Sandbox Code Playgroud)

我想得到添加键“t2p_conv”的结果。为此,我使用了 javascript 的 reduce 函数,如下所示:

let sumt2p = data.reduce((acc, item) => {
     return acc + item.t2p_conv;
});
console.log("Result: " + sumt2p);
Run Code Online (Sandbox Code Playgroud)

当我尝试显示 …

javascript

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

React:如何在独立组件之间传递数据

我知道如何将数据从一个组件传递到另一个组件,但我想做的是拥有两个独立的组件,其中一个组件将数据传递给另一个组件。

例如,<Component 1>将数据传递到<Component 2>. 我不想将数据传递到 的<Component 2>代码内部<Component 1>。我想知道是否可以传递数据以及如何从<Component 1><Component 2>。因为,我想要一个独立的组件来执行自己的任务,并在这些任务结束时将数据传递给不包含在她自己的代码中的其他组件。

这是我想做的一个例子:

class Test extends Component{
   constructor(){
       super()
   }

   render(){
      return(
         <div>
              <h1>Test</h1>
              <Component 1 />
              <Component 2 />
         </div>
      )
   }
}
Run Code Online (Sandbox Code Playgroud)

那么,React.js中有没有什么办法可以在独立组件之间传递数据呢?

reactjs

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