In PHP, an error is reported: “classweibo\\rests\\oauth2\datetimeAnalysis and Solution of Not Found”

1. In Yii 2, the error is reported: “classweibo\\rests\\oauth2\datetimenot found”


$urlSigner->signParams($route, false, (new DateTime())->add(new DateInterval('PT1H')));




{
    "name": "Exception",
    "message": "Class 'weibo\\rests\\oauth2\\DateTime' not found",
    "code": 0,
    "type": "Error",
    "file": "E:\\wwwroot\\channel-pub-api\\weibo\\rests\\oauth2\\AuthorizeAction.php",
    "line": 129,
    "stack-trace": [
        "#0 [internal function]: weibo\\rests\\oauth2\\AuthorizeAction->run()",
        "#1 E:\\wwwroot\\channel-pub-api\\vendor\\yiisoft\\yii2\\base\\Action.php(94): call_user_func_array(Array, Array)",
        "#2 E:\\wwwroot\\channel-pub-api\\vendor\\yiisoft\\yii2\\base\\Controller.php(157): yii\\base\\Action->runWithParams(Array)",
        "#3 E:\\wwwroot\\channel-pub-api\\vendor\\yiisoft\\yii2\\base\\Module.php(528): yii\\base\\Controller->runAction('authorize', Array)",
        "#4 E:\\wwwroot\\channel-pub-api\\vendor\\yiisoft\\yii2\\web\\Application.php(103): yii\\base\\Module->runAction('v1/oauth2/autho...', Array)",
        "#5 E:\\wwwroot\\channel-pub-api\\vendor\\yiisoft\\yii2\\base\\Application.php(386): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
        "#6 E:\\wwwroot\\channel-pub-api\\weibo\\web\\index.php(17): yii\\base\\Application->run()",
        "#7 {main}"
    ]
}


2. Since the namespace is used, in order to solve the problem of finding a class definition in the namespace, you need to add a preamble \ before the class name


$urlSigner->signParams($route, false, (new \DateTime())->add(new \DateInterval('PT1H')));


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.