亚马逊 API Laravel
Amazon API for Laravel
只是初步了解 PHP 框架?我看到 Zend 有一个很棒的 Amazon API 服务可用 http://framework.zend.com/manual/current/en/modules/zendservice.amazon.html#zendservice-amazon-itemlookup-example-asin。但是,发现 Zend 很难使用和安装 modules/build.
Laravel 是否有类似的内置亚马逊 API 服务包可用?
您有两个选择:
- 在 Packagist 上搜索合适的作曲家包
- 在 Laravel - https://github.com/zendframework/ZendService_Amazon
上自行使用 Zend 的 Amazon 包
安装包并像这样创建一个对象。
$amazon = new ZendService\Amazon\Amazon('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY');
您可以尝试 this package (AWS Service Provider for Laravel 5),为 Laravel 制作并与 AWS 服务直接相关。它更像是包装纸或类似的东西。
它与 ~5.1 完全兼容,但您应该也可以在 5.2 上正常使用。
如果有帮助请告诉我:)
编辑:抱歉,没有很好地理解这个问题。通过搜索我刚刚发现 this interesting package (apai-io). The documentation, that you can see here,有很多示例,从基本用法到高级主题。它完全与框架无关,因此您不应偶然发现与特定框架 and/or 实现相关的错误。
看来应该能满足你的需求。
如果您已经有api密钥和密钥,您可以直接使用api amazon scratchpad工具。
此工具允许您创建和测试您的应用程序到 Amazon 目录。
这个有用的工具还提供了 PHP 代码或 java.
http://webservices.amazon.it/scratchpad/index.html
例子
<?php
// Your AWS Access Key ID, as taken from the AWS Your Account page
$aws_access_key_id = "YOUR ACCESS KEY";
// Your AWS Secret Key corresponding to the above ID, as taken from the AWS Your Account page
$aws_secret_key = "YOU SECRET KEY";
// The region you are interested in
$endpoint = "webservices.amazon.it"; // or other..
$uri = "/onca/xml";
$params = array(
"Service" => "AWSECommerceService",
"Operation" => "ItemSearch",
"AWSAccessKeyId" => "YOUR ACCESS KEY",
"AssociateTag" => "YOUR PERSONAL TAG",
"SearchIndex" => "Electronics", // or other ...
"Keywords" => "phone", // or other..
"ResponseGroup" => "Images,ItemAttributes,Offers",
"Sort" => "price"
);
// Set current timestamp if not set
if (!isset($params["Timestamp"])) {
$params["Timestamp"] = gmdate('Y-m-d\TH:i:s\Z');
}
// Sort the parameters by key
ksort($params);
$pairs = array();
foreach ($params as $key => $value) {
array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
}
// Generate the canonical query
$canonical_query_string = join("&", $pairs);
// Generate the string to be signed
$string_to_sign = "GET\n".$endpoint."\n".$uri."\n".$canonical_query_string;
// Generate the signature required by the Product Advertising API
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $aws_secret_key, true));
// Generate the signed URL
$request_url = 'http://'.$endpoint.$uri.'?'.$canonical_query_string.'&Signature='.rawurlencode($signature);
echo "Signed URL: \"".$request_url."\"";
?>
只是初步了解 PHP 框架?我看到 Zend 有一个很棒的 Amazon API 服务可用 http://framework.zend.com/manual/current/en/modules/zendservice.amazon.html#zendservice-amazon-itemlookup-example-asin。但是,发现 Zend 很难使用和安装 modules/build.
Laravel 是否有类似的内置亚马逊 API 服务包可用?
您有两个选择:
- 在 Packagist 上搜索合适的作曲家包
- 在 Laravel - https://github.com/zendframework/ZendService_Amazon 上自行使用 Zend 的 Amazon 包
安装包并像这样创建一个对象。
$amazon = new ZendService\Amazon\Amazon('AMAZON_API_KEY', 'US', 'AMAZON_SECRET_KEY');
您可以尝试 this package (AWS Service Provider for Laravel 5),为 Laravel 制作并与 AWS 服务直接相关。它更像是包装纸或类似的东西。
它与 ~5.1 完全兼容,但您应该也可以在 5.2 上正常使用。
如果有帮助请告诉我:)
编辑:抱歉,没有很好地理解这个问题。通过搜索我刚刚发现 this interesting package (apai-io). The documentation, that you can see here,有很多示例,从基本用法到高级主题。它完全与框架无关,因此您不应偶然发现与特定框架 and/or 实现相关的错误。
看来应该能满足你的需求。
如果您已经有api密钥和密钥,您可以直接使用api amazon scratchpad工具。
此工具允许您创建和测试您的应用程序到 Amazon 目录。 这个有用的工具还提供了 PHP 代码或 java.
http://webservices.amazon.it/scratchpad/index.html
例子
<?php
// Your AWS Access Key ID, as taken from the AWS Your Account page
$aws_access_key_id = "YOUR ACCESS KEY";
// Your AWS Secret Key corresponding to the above ID, as taken from the AWS Your Account page
$aws_secret_key = "YOU SECRET KEY";
// The region you are interested in
$endpoint = "webservices.amazon.it"; // or other..
$uri = "/onca/xml";
$params = array(
"Service" => "AWSECommerceService",
"Operation" => "ItemSearch",
"AWSAccessKeyId" => "YOUR ACCESS KEY",
"AssociateTag" => "YOUR PERSONAL TAG",
"SearchIndex" => "Electronics", // or other ...
"Keywords" => "phone", // or other..
"ResponseGroup" => "Images,ItemAttributes,Offers",
"Sort" => "price"
);
// Set current timestamp if not set
if (!isset($params["Timestamp"])) {
$params["Timestamp"] = gmdate('Y-m-d\TH:i:s\Z');
}
// Sort the parameters by key
ksort($params);
$pairs = array();
foreach ($params as $key => $value) {
array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
}
// Generate the canonical query
$canonical_query_string = join("&", $pairs);
// Generate the string to be signed
$string_to_sign = "GET\n".$endpoint."\n".$uri."\n".$canonical_query_string;
// Generate the signature required by the Product Advertising API
$signature = base64_encode(hash_hmac("sha256", $string_to_sign, $aws_secret_key, true));
// Generate the signed URL
$request_url = 'http://'.$endpoint.$uri.'?'.$canonical_query_string.'&Signature='.rawurlencode($signature);
echo "Signed URL: \"".$request_url."\"";
?>