2016-12-13 32 views
2

我正在嘗試在PHP的podio API中創建一個項目。這裏是我的代碼:用podio api爲PHP創建項目

Podio::setup($client_id, $client_secret); 
Podio::authenticate_with_app($app_id, $app_token); 
// Create a field collection with some fields. 
// Be sure to use the external_ids of your specific fields 
$fields = new PodioItemFieldCollection(array(
    new PodioTextItemField(array("external_id"=>"first", "values"=> "Han")), 
    new PodioTextItemField(array("external_id"=>"last", "values"=> "Solo")) 
)); 
// Create the item object with fields 
// Be sure to add an app or podio-php won't know where to create the item 
$item = new PodioItem(array(
    'app' => new PodioApp($app_id), // Attach to app with app_id=$app_id 
    'fields' => $fields 
)); 

// Save the new item 
$item->save(); 

,但我得到的錯誤

Notice: Undefined index: request in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\lib\PodioError.php on line 11 

Fatal error: Uncaught PodioMissingRelationshipError: "Item is missing 
relationship to app" Request URL: Stack Trace: #0  C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php(66): PodioItem->save() #1 {main} thrown in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioItem.php on line 75 

我是否正確創建的項目?難道是因爲這個應用程序有更多的兩個領域? (我想設置'first''last',並將其他字段留空)

+0

代碼中沒有'request'索引。 –

+0

@u_mulder什麼是'request'索引? –

+0

你看到'注意:未定義索引:請求'。我在代碼中看不到單詞「request」。你呢? –

回答

1

問題是我的$app_id是一個字符串,它應該是一個整數。