aliyun / aliyun/aliyun-openapi-cpp-sdk
在VS2022中运行阿里云短信V1.0的c++版本示例报错:
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 104
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
#include
#include
#include <alibabacloud/core/AlibabaCloud.h>
#include <alibabacloud/core/CommonRequest.h>
#include <alibabacloud/core/CommonClient.h>
#include <alibabacloud/core/CommonResponse.h>
using namespace std;
using namespace AlibabaCloud;
int main( int argc, char** argv )
{
AlibabaCloud::InitializeSdk();
AlibabaCloud::ClientConfiguration configuration( "cn-qingdao" );
// specify timeout when create client.
configuration.setConnectTimeout(1500);
configuration.setReadTimeout(4000);
// Please ensure that the environment variables ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set.
AlibabaCloud::Credentials credential( getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"), getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET") );
/* use STS Token
credential.setSessionToken( getenv("ALIBABA_CLOUD_SECURITY_TOKEN") );
*/
AlibabaCloud::CommonClient client( credential, configuration );
AlibabaCloud::CommonRequest request(AlibabaCloud::CommonRequest::RequestPattern::RpcPattern);
request.setHttpMethod(AlibabaCloud::HttpRequest::Method::Post);
request.setDomain("dysmsapi.aliyuncs.com");
request.setVersion("2017-05-25");
request.setQueryParameter("Action", "SendSms");
auto response = client.commonResponse(request);
if (response.isSuccess()) {
printf("request success.\n");
printf("result: %s\n", response.result().payload().c_str());
} else {
printf("error: %s\n", response.error().errorMessage().c_str());
printf("request id: %s\n", response.error().requestId().c_str());
}
AlibabaCloud::ShutdownSdk();
return 0;
}
报错如下:
错误 C4996 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. test-2-alibaba D:\Visual Studio\Projects\test-2-alibaba D:\Visual Studio\Projects\test-2-alibaba\test-2-alibaba.cpp 19
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with test-2-alibaba.cpp at line 19 and reproduce the C4996 error in Visual Studio 2022 using the shown Alibaba Cloud V1.0 SMS example. Check the SDK's Windows guidance and whether this example is still supported; done means the example builds successfully while retaining its credential lookup behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100