2016-03-02 75 views
0

我已成功地使用core_cohort_add_cohort_members登錄了moodle羣組中的用戶,但是我收到了一條警告,可以幫助我避開此警告。我已經通過core_cohort_add_cohort_members成功登記了一個用戶,但得到了一個警告

這是我得到的警告。 { 「警告」:[]}

這裏是我的代碼

 $fname = 'core_cohort_add_cohort_members'; 

     /// Paramètres 
     $member = new stdClass(); 
     $member->cohorttype[type]='id'; 
     $member->cohorttype[value]=2; 
     $member->usertype[type]='id'; 
     $member->usertype[value]=8; 

     $members = array($member); 
     $par = array('members' => $members); 
     $rest_format = 'json'; 

     $Serve_Url = 'localhost/moodle' . '/webservice/rest/server.php'. '?wstoken=' . '72f102312fff135cbb4a301d9c7839ae' .'&wsfunction='. $fname; 
     require_once('curl.inc'); 
     $Rest_format = ($rest_format == 'json') ? '&moodlewsrestformat=' . $rest_format : ''; 
     $curl = new curl; 
     //if rest format == 'xml', then we do not add the param for backward compatibility with Moodle < 2.2 
     $rep = $curl->post($Serve_Url.$Rest_format, $par); 
     dpm($rep); 

回答

0

的警告陣列是在你的榜樣回覆爲空。 如果您想更加詳細地檢測到這一點,您可以始終只使用json_decode()回覆。你應該看到一個空的數組。

所以我認爲它的工作就像你想的那樣。

相關問題