function addActivity($title = NULL, $body = NULL, $groupId = NULL) { if (empty($title) || empty($body) || empty($groupId)) { throw new Exception("should specify title, body and groupId"); } $activity = new osapiActivity(); $activity->setTitle($title); $activity->setBody($body); $params = array('userId' => '@me', 'groupId' => $groupId, 'activity' => $activity); $batch = $this->osapi->newBatch(); $batch->add($this->osapi->activities->create($params), 'addActivity'); $result = $batch->execute(); }
/** * Tests osapiActivities->create() */ public function testCreate() { $response = '[{"data":null}]'; $this->osapi->provider->httpProvider->addResponse($response); $batch = $this->osapi->newBatch(); $activity = new osapiActivity(null, null); $activityBody = 'osapi test activity body'; $activityTitle = 'osapi test activity at ' . time(); $activity->setTitle($activityTitle); $activity->setBody($activityBody); $batch->add($this->osapi->activities->create(array('userId' => $this->userId, 'groupId' => '@friends', 'activity' => $activity))); $result = $batch->execute(); $canonicalBody = '[{"method":"activities.create","params":{"userId":["' . $this->userId . '"],"groupId":"@friends","activity":{"body":"' . $activityBody . '","mediaItems":[],"title":"' . $activityTitle . '"},"appId":"@app"},"id":null}]'; $lastRequest = $this->osapi->provider->httpProvider->getLastRequest(); $this->assertEquals($canonicalBody, $lastRequest['body']); }
public function testCreate() { $this->assertSupportedMethod('activities.create'); $datenow = date('Y-m-d h:i:s'); $batch = $this->suite->osapi->newBatch(); $activity = new osapiActivity(null, null); $activity->setTitle('osapi test activity at ' . $datenow); $activity->setBody('osapi test activity body'); $createParams = array('userId' => '@me', 'groupId' => '@self', 'appId' => '@app', 'activity' => $activity); $batch->add($this->suite->osapi->activities->create($createParams), 'createActivity'); $result = $batch->execute(); if ($result['createActivity'] instanceof osapiError) { $name = $this->suite->getName(); $code = $result['createActivity']->getErrorCode(); $message = $result['createActivity']->getErrorMessage(); if ($code == 417) { //TODO: Have the provider throw an over quota exception, since not every provider uses this code. $this->markTestSkipped("Creating an activity reported 417. Were you over quota? ({$message})"); return; } $this->fail(sprintf("%s failed to create an activity: %s (%s)", $name, $message, $code)); } }
function _sendActivity($case, $activity) { $spaceName = "Sugar Cases " . $case->case_number; $activity = $GLOBALS["current_user"]->full_name . ": " . $activity; $spaces_config = $this->_getConfig(); $provider = new osapiProvider("", "", "", "", $spaces_config["os_rpc_url"], "eXo Social", true, null); $auth = new osapiOAuth2Legged($spaces_config["os_oauth_key_name"], $spaces_config["os_oauth_key_secret"], $spaces_config["os_user"]); $osapi = new osapi($provider, $auth); $osactivity = new osapiActivity(); $osactivity->setTitle($activity); $osactivity->setBody($activity); $params = array('userId' => '@me', 'groupId' => "space:" . $spaceName, 'activity' => $osactivity); // Start a batch $batch = $osapi->newBatch(); $batch->add($osapi->activities->create($params)); $result = $batch->execute(); }
/** * Tests osapiActivity->getTitle() */ public function testGetTitle() { $title = 'Foo osapiActivity Title'; $this->osapiActivity->setTitle($title); $this->assertEquals($title, $this->osapiActivity->getTitle()); }