2017-08-17 67 views
1

我正在瀏覽用於生成安全API密鑰的Algolia文檔。請參閱文檔https://www.algolia.com/doc/tutorials/security/api-keys/secured-api-keys/how-to-restrict-the-search-to-a-subset-of-records-belonging-to-a-specific-user/如何在php中獲取Firebase UserID?

我使用JavaScript,但文檔列出了下面的代碼作爲一個PHP文件。

$index->setSettings([ 
    'attributesForFaceting' => [ 
    'filterOnly(viewable_by)' 
    ] 
    ]); 

$index->partialUpdateObject(
[ 
    'viewableBy' => [1, 2], 
    'objectID' => 'myID1' 
] 
); 

,然後將此

$currentUserID = 1; // Replace by the current user ID 

$securedApiKey = $client->generateSecuredApiKey(
'YourSearchOnlyApiKey', // Make sure to use a search key 
    [ 
'filters' => 'viewable_by:'.$currentUserID 
] 
); 

首先我知道firebase.auth()。currentUser.uid用於獲得在JavaScript中火力用戶ID的,我如何獲得PhP中的「currentUserID」,以及如何將我的php文件連接到我的JS文件?

回答

相關問題