由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 有谁懂 php 的?问个问题 (有包子)
相关主题
请教一个API设计的面试题Web Software Engineer (Full Stack) - AI Product
吹牛也不能这样吹Job: Web Developer/Trading Tool Programmer in Miami FL (Full Time)
贴两个三藩的软工工作设计题求解
error of create ASP.net project in Visual Studio 2013麻烦大家看看这个题目什么意思?
什么是mock test?access a server not through remote desktop service on windows
Amazon选组求建议我们最近招JAVA+Web Service的QA,有兴趣的短信给我
招Senior System Test EngineerT家 :: 面筋
请教大牛们:ML/DL的程序员招聘:Engineer @E la carte
相关话题的讨论汇总
话题: amazon话题: print话题: key话题: params话题: access
进入JobHunting版参与讨论
1 (共1页)
t***q
发帖数: 418
1
有谁懂 php 的?问个问题。
下面一段程序,print 那个 $formattedresponse 的时候,总是说amazon_access_key
没有 configure之类的, 类似的另外一个程序,写法类似,print $formattedresponse
的时候,就有结果。
还有,我不太懂php 里, variable 是怎么定义的, 定义了$amazon_access_key 后,
我试图在之后print, 但都说该变量没有define. 为什么? 我如果在之前,刚定义好了
的那里print, 仿佛问题更大。为什么?怎么把一开始设定的variable 打印出来呢?
这些 amazon keys 的 configure 到底哪里出错了?
多谢!
接触php 不多,觉得这个语言有点神.
ini_set('memory_limit', '10000M');
class GatherData extends Command
{
private $rtKey = 'xxxxxxx';
private $amazon;
private $amazon_access_key = null;
private $amazon_secret_key = null;
private $amazon_associate_tag = null;

print $amazon_access_key;
protected function configure()
{
$this
->setName('api:gatherdata')
->setDescription('Processes a file with title names and
retrieves their XXXX details from APIs')
;
}
/**
* setParameters
* An array of keys so we can access our AWS services. This is
configured via the
* parameters.yml file and loaded in console
*
* @param array Parameters
*
* @return null
*/
public function setParameters($params)
{
if (!isset($params['amazon_access_key']) || !isset($params['amazon_
secret_key']) || !isset($params['amazon_associate_tag']))
throw new Exception("Missing AWS parameters. Please configure
your parameters.yml file");
$this->amazon_associate_tag = $params['amazon_associate_tag'];
$this->amazon_secret_key = $params['amazon_secret_key'];
$this->amazon_access_key = $params['amazon_access_key'];
print $amazon_access_key;
}
public function initialize(InputInterface $input, OutputInterface $
output)
{
$conf = new GenericConfiguration();
$conf
->setCountry('com')
->setAccessKey($this->amazon_access_key)
->setSecretKey($this->amazon_secret_key)
->setAssociateTag($this->amazon_associate_tag);
$this->amazon = new ApaiIO($conf);
}
private function getAmazon($title)
{
$search = new Search();
$search->setCategory('XXX');
$search->setKeywords($title);
$formattedResponse = $this->amazon->runOperation($search);
print $formattedResponse;
s*******e
发帖数: 1630
2
真牛,公司代码直接贴出来了

key
formattedresponse

【在 t***q 的大作中提到】
: 有谁懂 php 的?问个问题。
: 下面一段程序,print 那个 $formattedresponse 的时候,总是说amazon_access_key
: 没有 configure之类的, 类似的另外一个程序,写法类似,print $formattedresponse
: 的时候,就有结果。
: 还有,我不太懂php 里, variable 是怎么定义的, 定义了$amazon_access_key 后,
: 我试图在之后print, 但都说该变量没有define. 为什么? 我如果在之前,刚定义好了
: 的那里print, 仿佛问题更大。为什么?怎么把一开始设定的variable 打印出来呢?
: 这些 amazon keys 的 configure 到底哪里出错了?
: 多谢!
: 接触php 不多,觉得这个语言有点神.

t***q
发帖数: 418
3
哦,你懂吗?我没办法就帖了。

【在 s*******e 的大作中提到】
: 真牛,公司代码直接贴出来了
:
: key
: formattedresponse

l******t
发帖数: 9
4
print $this->amazon_access_key
$this->amazon_access_key -> class variable
$amazon_access_key -> local variable
你不应该在class scope print, 一般class scope只定义class variable. 你可以在
setParameters() function里print_r($params)看传了什么value.
t***q
发帖数: 418
5
好牛,我试试,发包子,我还想问一下,为什么 print $formattedResponse 就有结果
?那是在一个函数里。php 函数里可以随便 print, class 里就不行?多谢!

【在 l******t 的大作中提到】
: print $this->amazon_access_key
: $this->amazon_access_key -> class variable
: $amazon_access_key -> local variable
: 你不应该在class scope print, 一般class scope只定义class variable. 你可以在
: setParameters() function里print_r($params)看传了什么value.

t***q
发帖数: 418
6
还有我一直不能理解的是为什么这个php 就不能 configure。哪里有问题?还有我不懂
得是参数是怎么从 parameters.yml file 传上去的?好神奇。

【在 l******t 的大作中提到】
: print $this->amazon_access_key
: $this->amazon_access_key -> class variable
: $amazon_access_key -> local variable
: 你不应该在class scope print, 一般class scope只定义class variable. 你可以在
: setParameters() function里print_r($params)看传了什么value.

l******t
发帖数: 9
7

我不是牛人,只是平时工作用到PHP, :), PHP主要有三个scope: global, class,
local
$globalVar = "a"; // global variable
class test {
private $classVar = "b"; // class varible
public function print_variable() {
print $globalVar; // print nothing and raise an variable undefined
notice
global $globalVar;
print $globalVar // print a
print $classVar; // print nothing and raise an variable undefined
notice
print $this->classVar // print b
$localVar = "c"; // local variable
print $localVar; // print c
}
}

【在 t***q 的大作中提到】
: 好牛,我试试,发包子,我还想问一下,为什么 print $formattedResponse 就有结果
: ?那是在一个函数里。php 函数里可以随便 print, class 里就不行?多谢!

t***q
发帖数: 418
8
Thank you so much!

【在 l******t 的大作中提到】
:
: 我不是牛人,只是平时工作用到PHP, :), PHP主要有三个scope: global, class,
: local
: $globalVar = "a"; // global variable
: class test {
: private $classVar = "b"; // class varible
: public function print_variable() {
: print $globalVar; // print nothing and raise an variable undefined
: notice
: global $globalVar;

l******t
发帖数: 9
9

PHP可以parse and read yml file, 应该是parser parse yml file,把变量存在array
, 然后再call setParameters($params)

【在 t***q 的大作中提到】
: 还有我一直不能理解的是为什么这个php 就不能 configure。哪里有问题?还有我不懂
: 得是参数是怎么从 parameters.yml file 传上去的?好神奇。

t***q
发帖数: 418
10
多谢,我想进一步问问,它的parse 是自动的吗?还是作者写了一个php script ,然
后那个 script parse. 我的原始程序有5,6 个 piece.还有 yml file. 在一个叫
xampp 的platform 上 run.

array

【在 l******t 的大作中提到】
:
: PHP可以parse and read yml file, 应该是parser parse yml file,把变量存在array
: , 然后再call setParameters($params)

相关主题
Amazon选组求建议Web Software Engineer (Full Stack) - AI Product
招Senior System Test EngineerJob: Web Developer/Trading Tool Programmer in Miami FL (Full Time)
请教大牛们:ML/DL的程序员设计题求解
进入JobHunting版参与讨论
t***q
发帖数: 418
11
我再发一个包子吧。看你说了这么多。多谢!

【在 t***q 的大作中提到】
: 多谢,我想进一步问问,它的parse 是自动的吗?还是作者写了一个php script ,然
: 后那个 script parse. 我的原始程序有5,6 个 piece.还有 yml file. 在一个叫
: xampp 的platform 上 run.
:
: array

t********5
发帖数: 522
12
好心提醒一句 如果是公司代码 lz问完问题赶紧把这帖子删了吧
t***q
发帖数: 418
13
确实,我看了,原作者有一个console.php 就是 configure yml file 的。

array

【在 l******t 的大作中提到】
:
: PHP可以parse and read yml file, 应该是parser parse yml file,把变量存在array
: , 然后再call setParameters($params)

t***q
发帖数: 418
14
会的。

【在 t********5 的大作中提到】
: 好心提醒一句 如果是公司代码 lz问完问题赶紧把这帖子删了吧
t***q
发帖数: 418
15
print $formattedResponse 后就会有这个错。见附件。
t***q
发帖数: 418
16
t***q
发帖数: 418
17
错误说 missing client token id, request must contain AWSAccessKeyID or x.509
certificate. ItemSearchErrorrResponse
不晓得是哪里出错了?是说AWSAccessKeyID 没有传输到initialize 那个function 里
吗?
多谢!
1 (共1页)
进入JobHunting版参与讨论
相关主题
招聘:Engineer @E la carte什么是mock test?
做restful API,有前途么?Amazon选组求建议
[合集] Amazon Onsite 面试题招Senior System Test Engineer
这种情况告诉他们我可以OPT27个月有用么?请教大牛们:ML/DL的程序员
请教一个API设计的面试题Web Software Engineer (Full Stack) - AI Product
吹牛也不能这样吹Job: Web Developer/Trading Tool Programmer in Miami FL (Full Time)
贴两个三藩的软工工作设计题求解
error of create ASP.net project in Visual Studio 2013麻烦大家看看这个题目什么意思?
相关话题的讨论汇总
话题: amazon话题: print话题: key话题: params话题: access