gladiopeace / opensocial-php-client

Automatically exported from code.google.com/p/opensocial-php-client
Apache License 2.0
0 stars 0 forks source link

mediaItems on activities #76

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

 - Use the client to retrieve activities that contains mediaItems
 - First create a activity with a mediaItem:
$osapi    = new osapi($provider, $signer);
$batch    = $osapi->newBatch();
$activity = new osapiActivity();
$activity->setTitle($_POST['title']);
$activity->setBody($_POST['body']);
$mediaItem = new osapiMediaItem();
$mediaItem->setField('url', 'http://10.0.0.15/~luis/1160_token2a.jpg');
$mediaItem->setField('mimeType', 'image/jpeg');
$mediaItem->setField('type', 'IMAGE');
$activity->setMediaItems(array($mediaItem));
$requests = $osapi->activities->create(array(
                                       'userId'   => '@me',
                                       'groupId'  => '@self',
                                       'activity' => $activity,
                                  ));
$batch->add($request);
try {
  $result = $batch->execute();
} catch (Exception $e) {
  $error = $e->getMessage();
}

Then retrieve the activities using the client:

$osapi    = new osapi($provider, $signer);
$batch    = $osapi->newBatch();
$request  = $osapi->activities->get(array(
                                       'userId'  => '@me',
                                       'groupId' => '@self',
                                  ));
$batch->add($request, 'get_activities');
try {
  $result     = $batch->execute();
  $activities = $result['get_activities'];
  $arrAct     = $activities->getList();
  $activity   = $arrAct[0];
  var_dump($activity);
} catch (Exception $e) {
  $error = $e->getMessage();
}

What is the expected output? 

object(osapiActivity)[14]
  public 'appId' => int 84
  public 'body' => string 'This activity contains a media item' (length=35)
  public 'bodyId' => string '' (length=0)
  public 'externalId' => string '' (length=0)
  public 'id' => string '17818433' (length=8)
  public 'mediaItems' => 
    array
      0 => 
        object(osapiMediaItem)[15]
          public 'mimeType' => string 'image/jpeg' (length=10)
          public 'type' => string 'IMAGE' (length=5)
          public 'url' => string 'http://10.0.0.15/~luis/1160_token2a.jpg' (length=39)
  public 'postedTime' => string '2010-11-12 04:02:21 PM' (length=22)
  public 'priority' => string '0' (length=1)
  public 'streamTitle' => string '' (length=0)
  public 'title' => string 'Media Item Activity' (length=19)
  public 'titleId' => string '' (length=0)
  public 'userId' => string '133244556257' (length=6)

What do you see instead?

object(osapiActivity)[14]
  public 'appId' => int 84
  public 'body' => string 'This activity contains a media item' (length=35)
  public 'bodyId' => string '' (length=0)
  public 'externalId' => string '' (length=0)
  public 'id' => string '17818433' (length=8)
  public 'mediaItems' => 
    array
      0 => 
        object(osapiMediaItem)[15]
  public 'postedTime' => string '2010-11-12 04:02:21 PM' (length=22)
  public 'priority' => string '0' (length=1)
  public 'streamTitle' => string '' (length=0)
  public 'title' => string 'Media Item Activity' (length=19)
  public 'titleId' => string '' (length=0)
  public 'userId' => string '133244556257' (length=6)

What version of the product are you using? On what operating system?

URL: http://opensocial-php-client.googlecode.com/svn/trunk
Last Changed Rev: 212
openSUSE 11.3 "Teal" - Kernel
Linux sys-lj 2.6.34.7-0.5-default #1 SMP 2010-10-25 08:40:12 +0200 x86_64 
x86_64 x86_64 GNU/Linux

Please provide any additional information below.

I attach the patch to fix that behavior.

The problem is on the osapiActivites service call a constructor that doesn't 
exist on the osapiMediaItem

Original issue reported on code.google.com by ing.lu...@gmail.com on 12 Nov 2010 at 4:55

Attachments: