TypeScript call function with Rest Parameters from another with Rest Parameters
Date : March 29 2020, 07:55 AM
will help you Try the Spread Operator. It should allow for the same effect as in Jeffery's answer but has a more concise syntax. function test2(p1: string, ...p2: string[]) {
test1(...arguments);
}
|
Yii2: REST POST request parameters not arriving to action
Tag : php , By : Grace Jones
Date : March 29 2020, 07:55 AM
wish helps you It appears the problem was not in Yii2 at all. After checking our GoDaddy configuration we found our A Record was pointing to the wrong IP.
|
Yii2 route using yii\rest\UrlRule with several parameters
Date : March 29 2020, 07:55 AM
To fix the issue you can do So I figured out how to use more complex rules. First, the solution, then the explanation. 'rules' => [
... previous rules ...,
[
'class' => 'yii\rest\UrlRule',
'controller' => 'game',
'prefix' => '/users/<userid:\\d+>',
'tokens' => [
'{gameid}' => '<gameid:\\d+>',
],
'patterns' => [
'GET,HEAD' => 'index',
'GET,HEAD {gameid}' => 'view',
]
]
]
|
Yii2 Url Manager allow plus (+) in url
Date : March 29 2020, 07:55 AM
I hope this helps you . The plus sign is one of the ways to encode a space in the URL. By the time the URL is passed to the UrlManager's rules, it has already been decoded. So if you open http://example.com/page/page+with+spaces in your browser, the string passed to the rule will actually look like this: /page/page with spaces.
|
Use Yii2 REST client to consume Yii2 REST API
Date : March 29 2020, 07:55 AM
it helps some times I am not sure if you need to extend outh2 class as I believe you don't have the authentication logic completed in the first Yii2 webapp, like authenticating using first webapp url then redirect to the second webapp to extract the token from url. It could be simpler just create a component that have those methods class YourRestClient {
const BASE_URL = 'https://example.com/api/v3';
private $_token = null;
public function authenticate($username,$password){
$client = new Client();
$response = $client->createRequest()
->setMethod('POST')
->setUrl(BASE_URL.'/user/login')
->setData(['username' => $username, 'password' => $password])
->send();
if ($response->isOk) {
$this->_token = $response->data['token'];
}
}
public function logout(){
//your logut logic
}
public function refreshToken(){
//your refresh logic
}
public function userList(){
$client = new Client();
$response = $client->createRequest()
->setMethod('GET')
->setUrl(BASE_URL.'/user/users')
->addHeaders([
'content-type' => 'application/json',
'Authorization' => 'Bearer '.$_token,
])
->send();
if ($response->isOk) {
return $response->getData();
}
}
}
|