尝试访问 Microsoft Graph 时出现“无法获得本地颁发者证书”

我想将我的 Symfony4 应用程序配置为使用msgraph-sdk-php库读取和发送电子邮件。


我的第一次经历是这段代码:


    $guzzle = new \GuzzleHttp\Client();

    $url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=1.0';

    $token = json_decode($guzzle->post($url, [

        'form_params' => [

            'client_id' => $clientId,

            'client_secret' => $clientSecret,

            'resource' => 'https://graph.microsoft.com/',

            'grant_type' => 'client_credentials',

        ],

        'verify' => false

    ])->getBody()->getContents());

    $accessToken = $token->access_token;


    $graph = new Graph();

    $graph->setAccessToken($accessToken);


    try {

        $user = $graph->createRequest("GET", "/me")

            ->setReturnType(User::class)

            ->execute();

    } catch (GraphException $e) {

        $user=(object) ['getGivenName'=>$e->getMessage()];

    }


    return "Hello, I am $user->getGivenName() ";

但是随后 Symfony 向我显示了一个带有此消息的异常页面:


cURL 错误 60:SSL 证书问题:无法获取本地颁发者证书


我应该怎么做才能克服这个问题?


米脂
浏览 128回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP