有人帮我解决了这个问题,当我运行文件 token.php 在我的终端中时,我无法获取AccessToken。
当我运行它在终端时我得到这样的错误:
/token.php - Class' Twilio \ Jwt \ AccessToken'在第26行的/Users/xxx/Desktop/GETFolder/token.php中找不到
<?php
include('./vendor/autoload.php');
include('./config.php');
include('./randos.php');
use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants\IpMessagingGrant;
$appName = 'ChatQuickstart';
$TWILIO_ACCOUNT_SID='xxxxxxx';
$TWILIO_API_KEY='xxxxxxx';
//$TWILIO_API_SECRET='xxxxxxxx';
$identity = "NAYEEM";
$deviceId = $_GET['device'];
$endpointId = $appName . ':' . $identity . ':' . $deviceId;
$token = new AccessToken(
$TWILIO_ACCOUNT_SID,
$TWILIO_API_KEY,
$TWILIO_API_SECRET,
3600,
$identity
);
$grant = new IpMessagingGrant();
$grant->setServiceSid($TWILIO_IPM_SERVICE_SID);
$grant->setEndpointId($endpointId);
$token->addGrant($grant);
echo json_encode(array(
'identity' => $identity,
'token' => $token->toJWT(),
));