2012-04-23 66 views
0

有人可以看看我如何設置此REST調用?我一直無法找到一個這樣的例子,我不能得到它的工作。sugarcrm REST get_entry

它可能是空白的'link_name_to_fields_array'參數。我已閱讀文檔,並不真正瞭解該參數。我不知道這是否會導致我的問題。

任何幫助將是有益的。

//SET UP CURL 
$curl = curl_init($url); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_HEADER, false); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 

//parameters for get_entry call (I received a session id from a call to the login function. Using it here) 
//I manually got this user 'id' form the sugarcrm database 
$parameters = array(
     'session'=>$result->id, 
     'module_name' => 'users', 
     'id' => '21a6a633-40de-9bf4-aa14-4f8753ea5aa2', 
     'select_fields' => array('user_name'), 
     'link_name_to_fields_array'=> array() 
); 


$json = json_encode($parameters); 
$postArgs='method=get_entry&input_type=JSON&response_type=JSON$rest_data=' . $json; 
curl_setopt($curl,CURLOPT_POSTFIELDS, $postArgs); 
$result2 = curl_exec($curl); 
echo("<pre>" . print_r($result2,true) . "</pre>"); 

輸出爲 「傳入壞數據;返回首頁

回答

2

你必須在postArgs線錯誤(更換$rest_data&rest_data)。試試這個:

$postArgs='method=get_entry&input_type=JSON&response_type=JSON&rest_data=' . $json; 
+0

謝謝!多麼愚蠢的錯誤。 :-P – benino 2012-05-14 22:05:25