2016-12-01 64 views
2

我正在嘗試將聯繫人添加到聯繫人字段,該字段當前在應用中沒有任何信息。我最初嘗試通過應用程序認證,但發現這個職位on Podio forum和這個on here和改變認證到用戶。ID爲#的用戶沒有正確的配置文件ID#

用戶是工作區管理員,我添加的profile_id是工作區成員,應用程序對它沒有任何限制。

我錯過了什麼,如何解決問題?

$item_id = 1111111; 
$field_id = 2222222; 
$profile_id = 3333333; 

Podio::authenticate_with_password('admin_user_email', 'password'); 
$item = PodioItem::get_basic($item_id); 
$external_id = 'sign-off-authority'; 
$contact = new PodioContactItemField(array('field_id' => $field_id, 'external_id' => $external_id, 'values' => array('profile_id' => $profile_id))); 
$item->fields[] = $contact; 
$item->save(); 

導致以下堆棧跟蹤:

Fatal error: 
Uncaught PodioForbiddenError: 
"The user with id #### does not have the right view on profile with id ####" 
Request URL: http://api.podio.com/item/1111111 Stack Trace: 
#0 C:\xampp\htdocs\podio-api\lib\Podio.php(322): Podio::request('PUT', '/item/1111111', Array) 
#1 C:\xampp\htdocs\podio-api\models\PodioItem.php(184): Podio::put('/item/1111111', Array) 
#2 C:\xampp\htdocs\podio-api\models\PodioItem.php(67): PodioItem::update(1111111, Array, Array) 
#3 C:\xampp\htdocs\getItems.php(48): PodioItem->save() 
#4 {main} thrown in C:\xampp\htdocs\podio-api\lib\Podio.php on line 286 
+0

你確定你沒有混合user_id和profile_id嗎? –

+0

是的,我做了一個獲取所有工作區成員的請求,以找到他們的profile_id的&確保他們是工作區成員 – APW

回答

1

我發現PHP或波迪奧的PHP API庫我的存儲值轉換成一個數組,而不是將其保留爲一個整數值。我試圖使用user_id和profile_id都沒有工作,直到我通過輸出日誌意識到發生了什麼。我不得不更新代碼這樣:通過創建一個數組並添加該物體它保留它的預設格式,並通過該API接受

$profile_id = 3333333; 
$arr = []; 
$arr['profile_id'] = $profile_id; 
$contact = new PodioContactItemField(array('field_id' => $field_id, 'external_id' => $external_id, 'values' => $arr)); 

。現在代碼運行良好。

1

它的工作原理我使用user_id,而不是profile_id的。你可以試試嗎?

這裏是工作示例的紅寶石

Podio.client.authenticate_with_credentials(<user_email>, <user_password>) 
field_external_id = 'requester' 
field_new_value = [{'value' => {'type' => 'user', 'id' => <some_other_user_id>}}, 
        {'value' => {'type' => 'user', 'id' => <different_user_id>}}] 
Podio::ItemField.update(item_id, field_external_id, field_new_value) 
+0

謝謝,但這並沒有幫助我在這種情況下。 – APW