/**
 * Create a new Message in the default thread for the runid
 * @param $usertoken the ARLearn user token to append to the app key when sending the onBehalfOf token (as created with function createARLearnUserToken)
 * @param $runId the ARLearn runId
 * @param $message_content the message content
 * @return false, if the attempt failed, else the response data from the ARLearn service call (will be a json string).
 */
function createARLearnDefaultThreadMessage($usertoken, $runId, $message_content)
{
    $threadId = getARLearnRunDefaultThreadId($usertoken, $runId);
    if ($threadId != false) {
        $response = createARLearnMessage($usertoken, $runId, $threadId, $message_content);
        return $response;
    }
    return false;
}
示例#2
0
function wespot_msg_get_default_thread_id($group_guid)
{
    elgg_load_library('elgg:wespot_arlearnservices');
    elgg_load_library('elgg:wespot_arlearnmsgservices');
    if (!($game = wespot_msg_get_game($group_guid))) {
        return false;
    }
    $group = get_entity($group_guid);
    $runId = $game->arlearn_runid;
    $owner_guid = $group->owner_guid;
    $ownerprovider = elgg_get_plugin_user_setting('provider', $owner_guid, 'elgg_social_login');
    $owneroauth = str_replace("{$ownerprovider}_", '', elgg_get_plugin_user_setting('uid', $owner_guid, 'elgg_social_login'));
    $usertoken = createARLearnUserToken($ownerprovider, $owneroauth);
    if (isset($usertoken) && $usertoken != "") {
        return getARLearnRunDefaultThreadId($usertoken, $runId);
    }
    return false;
}