dpf71390 2011-01-19 06:19
浏览 23
已采纳

亚马逊ec2查询制作

Can any one tell an idea to create a query for describing regions in aws ec2.I confused in &authparameters .Also please give a program to generate signature .

  • 写回答

3条回答 默认 最新

  • dousi1994 2011-01-21 06:50
    关注

    After a longtime search i found a program that will create a query and returns the response from AWS..It works fine..

    Program

    <?php 
    
    $key='Your aws key';
     $pwd='Your AWS secret key';
    
    
    
    // See docs   ://docs.amazonwebservices.com/AWSEC2/latest/APIReference/------->Actions---->Describe Regions 
    
    //for making a request to the aws
    
    
     $params = array(   
     'Action' => 'DescribeAvailabilityZones',
     'AWSAccessKeyId' => $key, 
     'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'),
     'Version' => '2008-05-05', 
     'ZoneName.0' => 'us-east-1a',
     'ZoneName.1' => 'us-east-1b',    
     'ZoneName.2' => 'us-east-1c', 
     'SignatureVersion' => 2,  
     'SignatureMethod' => 'HmacSHA256'
     );
    
    
    
    
     uksort($params, 'strnatcmp');
     $qstr = ''; 
     foreach ($params as $key => $val) {
     $qstr .= "&{$key}=".rawurlencode($val);
     }
     $qstr = substr($qstr, 1);
    
     // Signature Version 2 
    
     $str = "GET
    "  
     . "ec2.amazonaws.com
    "
     . "/
    "      
     . $qstr; 
    
    
     $params['Signature'] = base64_encode( hash_hmac('sha256', $str, $pwd, true) );  // Generating a base64-encoded RFC 
    
    //2104-compliant HMAC-SHA256 
    
    
    
     $req = 'https://ec2.amazonaws.com/?' . http_build_query(     $params );  // encoded query string 
    
     echo '<a href="'.$req.'">XML</a><p>';//For Navigating or creating a request.
    
    
    
     ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?