Preview release of a radically changed PHP client library (1.0)

0 views
Skip to first unread message

Arne Roomann-Kurrik

unread,
Feb 6, 2009, 8:13:31 PM2/6/09
to opensocial-client-libraries
If you've been developing using the 0.2 release of the PHP client
library, I've just posted a new version which changes the structure of
the library pretty significantly. The updated library is mostly
written by Chris Chabot (who also wrote PHP Shindig and Partuza) and
supports the entire OpenSocial specification, including XRDS and 3-
legged OAuth support.

Next week we'll be finishing up the unit tests, documentation, and
samples for the library before pushing it into SVN (and overwriting
the current library). Until then, you can familiarize yourself with
the changes by downloading the preview release, which is posted here:

http://opensocial-php-client.googlecode.com/files/opensocial-php-client-1.0preview.zip

Note that this isn't a drop-in release, as the class names and calling
conventions have changed. For an example on how to use the new
syntax, view the example source in /examples/listFriends.php

If you have any questions, please post them here!

~Arne

SocialMatrix

unread,
Feb 12, 2009, 2:12:46 AM2/12/09
to opensocial-client-libraries
Hi,

If someone can please post an example of how to use getFieldByName()
that would be really helpful. I am looking for something similar to
showperson.php example from previous client library.

in the osapi\src\model I see there is a osapiPerson.php that seems to
get us access to fields like age, book, music, movies etc.. However, I
couldn't figure out how to call this function in my application. I
need to access some of these fields.

Thank You,
Atit

On Feb 6, 6:13 pm, Arne Roomann-Kurrik <api.kur...@google.com> wrote:
> If you've been developing using the 0.2 release of the PHP client
> library, I've just posted a new version which changes the structure of
> the library pretty significantly.  The updated library is mostly
> written by Chris Chabot (who also wrote PHP Shindig and Partuza) and
> supports the entire OpenSocial specification, including XRDS and 3-
> legged OAuth support.
>
> Next week we'll be finishing up the unit tests, documentation, and
> samples for the library before pushing it into SVN (and overwriting
> the current library).  Until then, you can familiarize yourself with
> the changes by downloading the preview release, which is posted here:
>
> http://opensocial-php-client.googlecode.com/files/opensocial-php-clie...

yelims

unread,
Feb 12, 2009, 5:20:37 AM2/12/09
to opensocial-client-libraries
Hi

you said you will provide documentation (and its badly needed)

please please provide examples on how to:

* how can a user "join" or "signup" to our sites (like friendconnect?)
* how can user login
* how to persist user session on our servers
* how to retrieve unique user id and username


so far i am very disappointed about opensocial, alot of hype and
little substance

yes i am being pragmatic, it be great if users with google and other
open accounts could login to my site and my application could
authorize them to do things such as add content etc

Regards

Arne Roomann-Kurrik

unread,
Feb 12, 2009, 12:20:54 PM2/12/09
to opensocial-client-libraries
I'm currently working on an example that will show you how to do these
things- my apologies if you feel like there hasn't been much substance
so far.

SocialMatrix, I'll make sure to get a sample like that created by next
week.

~Arne

yelims

unread,
Feb 12, 2009, 3:27:40 PM2/12/09
to opensocial-client-libraries
Thank you very much!

ill keep subscribed

btw the code looks well written from a quick look

maybe submit it to be part of Zend Framework to gain wider exposure?

Regards

Arne Roomann-Kurrik

unread,
Feb 12, 2009, 3:37:42 PM2/12/09
to opensocial-client-libraries
Zend's releasing limitations would prevent us from iterating as
quickly as we'd like on the library. Until the codebase becomes more
stable, we'd prefer to remain independent.

~Arne

Atit Thekdi

unread,
Feb 12, 2009, 5:08:40 PM2/12/09
to opensocial-cl...@googlegroups.com
Thanks Arne,

I am not looking for full blown example. I just wanted to find out how to get additional fields like, age, book, music, movies etc...

One thing I tried are, modified following code

$batch->add($osapi->people->get(array('userId' => $userId, 'groupId' => '@self')), 'self');

to

$batch->add($osapi->people->get(array('userId' => $userId, 'groupId' => '@self, 'fields' => '@all')), 'self');

However, this doesn't work. Any other suggestions to extract additional fields?

Apologies for repeating same question, I am under tight deadline to defend my thesis.

Thank You,
Atit

Chris Chabot

unread,
Feb 12, 2009, 5:26:17 PM2/12/09
to opensocial-cl...@googlegroups.com
Try this:
'fields' => array('@all')

This doesn't however mean that every social networking site exports all the fields it knows about unfortunately, it's completely upto the container which fields they do or do not want to support (and if your favorite field is missing, please complain on the container's own forums:)

   -- Chris

Chris Chabot

unread,
Feb 12, 2009, 5:27:51 PM2/12/09
to opensocial-cl...@googlegroups.com
glad you liked the code :)

If you take this library, use 2 or 3 legged oauth, and possibly OpenID (yahoo/google/etc accounts) for the user authentication, you should be covered for the requirements you mentioned.

   -- Chris

Atit Thekdi

unread,
Feb 12, 2009, 5:31:58 PM2/12/09
to opensocial-cl...@googlegroups.com
Thanks a lot Chris,

does Orkut support this?

I tried, following and had no success :(

 $batch->add($osapi->people->get(array('userId' => $userId, 'groupId' => '@self', 'fields' => array('@all'))), 'self');

Chris Chabot

unread,
Feb 12, 2009, 5:41:46 PM2/12/09
to opensocial-cl...@googlegroups.com
Just tried, and no unfortunately that doesn't work on Orkut, it returns *no* fields when you tell it to return all, doh :)

You can verify that it does understand the 'fields' param by doing something like: 'fields' => array('displayName','name','age','gender','aboutMe')

   -- Chris

Atit Thekdi

unread,
Feb 12, 2009, 5:57:35 PM2/12/09
to opensocial-cl...@googlegroups.com
Yes Yes Yes...that works. Thank you so much :) You rock.

However, it didn't work for my friends :(

e.g this doesn't work :(

 $batch->add($osapi->people->get(array('userId' => $userId, 'groupId' => '@friends', 'count' => 20, 'fields' => array('displayName','name','age','gender','aboutMe', 'movies', 'activities'))), 'friends');

Atit

Arne Roomann-Kurrik

unread,
Feb 12, 2009, 6:07:28 PM2/12/09
to opensocial-client-libraries
Hi Atit,

Orkut won't return extended profile fields for users who have not
elected to share information with your app. Currently, the only way
that an orkut user can share information with your site is to install
the gadget associated with the consumer key and secret you are
using.

Once orkut supports 3-legged oauth, you'll be able to pop up a window
to orkut that will ask a user to log in and share access - until then
you can ask them to install your application.

~Arne


On Feb 12, 2:57 pm, Atit Thekdi <thekdis...@gmail.com> wrote:
> Yes Yes Yes...that works. Thank you so much :) You rock.
>
> However, it didn't work for my friends :(
>
> e.g this doesn't work :(
>
>  $batch->add($osapi->people->get(array('userId' => $userId, 'groupId' =>
> '@friends', 'count' => 20, 'fields' =>
> array('displayName','name','age','gender','aboutMe', 'movies',
> 'activities'))), 'friends');
>
> Atit
>
> On Thu, Feb 12, 2009 at 3:41 PM, Chris Chabot <chab...@google.com> wrote:
> > Just tried, and no unfortunately that doesn't work on Orkut, it returns
> > *no* fields when you tell it to return all, doh :)
>
> > You can verify that it does understand the 'fields' param by doing
> > something like: 'fields' =>
> > array('displayName','name','age','gender','aboutMe')
>
> >    -- Chris
>
> > On Thu, Feb 12, 2009 at 11:31 PM, Atit Thekdi <thekdis...@gmail.com>wrote:
>
> >> Thanks a lot Chris,
>
> >> does Orkut support this?
>
> >> I tried, following and had no success :(
>
> >>  $batch->add($osapi->people->get(array('userId' => $userId, 'groupId' =>
> >> '@self', 'fields' => array('@all'))), 'self');
>
> >> On Thu, Feb 12, 2009 at 3:26 PM, Chris Chabot <chab...@google.com> wrote:
>
> >>> Try this:
> >>> 'fields' => array('@all')
>
> >>> This doesn't however mean that every social networking site exports all
> >>> the fields it knows about unfortunately, it's completely upto the container
> >>> which fields they do or do not want to support (and if your favorite field
> >>> is missing, please complain on the container's own forums:)
>
> >>>    -- Chris
>

cornelius

unread,
Feb 12, 2009, 6:47:52 PM2/12/09
to opensocial-client-libraries
Hello

not sure if this was mentioned, but some thing like this would be
great (amybe tutorial?)

1. using friend connect to add login / signup to site (this is very
easy to do and involves no php)
2. once the user is signed in to the site via friend connect plugin
thingies how will the underlying php app create and mantain a session
(via this library?) and find the username the user chose on signup?
and some sort of unique identifier?
3. once you have a session you can allow the user to do variety of
tasks on the site such as upload files, leave comments etc

Basically how does googles friendconnect, opensocial apis and this
library all fit together?

I have no issues writing yet another signup/login system but i hope on
my next project i could avoid this and just have users login with
their google accounts (or whatever else is on opensocial)

I hope im making sense

Thank you

Atit Thekdi

unread,
Feb 12, 2009, 6:48:04 PM2/12/09
to opensocial-cl...@googlegroups.com
Thanks Arne, I'll do that.

Atit Thekdi

unread,
Feb 12, 2009, 7:38:01 PM2/12/09
to opensocial-cl...@googlegroups.com
Hi,

In order to have my friends install the gadget associated with my consumer key and secret, do I have to get it listed in the Application Directory?

Essentially, I am not building an application. I just need data. For my thesis, I am trying to match people's orkut profile with facebook profile, "Algorithmically". This is why I need meta-data about people (there are lots of "John Peterson" so just comparing names doesn't work).

So, is there anyway, I can ask my friends to install my application without getting it listed in the Application Directory?

Thank You for your time and considerations,
Sincerely,
Atit

Arne Roomann-Kurrik

unread,
Feb 12, 2009, 7:56:28 PM2/12/09
to opensocial-client-libraries
For your purposes, you could direct users to install an app on
sandbox.orkut.com and their information would be available for you to
access via REST. You could generate a link like the following:

http://sandbox.orkut.com/Main#AppInfo.aspx?appUrl=http://<server>/<path>/<to>/gadget.xml

If you wanted to be alerted whenever someone installed that gadget,
your gadget could do a signed gadgets.io.makeRequest call back to your
server, which would transmit their ID number back to your website (and
let you fetch their data via REST).

Of course, this approach doesn't let you crawl all of orkut's data,
but that's certainly by design. I don't believe that Facebook lets
you query profile data of users who have not authorized your app
access to this data, either.

~Arne


On Feb 12, 4:38 pm, Atit Thekdi <thekdis...@gmail.com> wrote:
> Hi,
>
> In order to have my friends install the gadget associated with my consumer
> key and secret, do I have to get it listed in the Application Directory?
>
> Essentially, I am not building an application. I just need data. For my
> thesis, I am trying to match people's orkut profile with facebook profile,
> "Algorithmically". This is why I need meta-data about people (there are lots
> of "John Peterson" so just comparing names doesn't work).
>
> So, is there anyway, I can ask my friends to install my application without
> getting it listed in the Application Directory?
>
> Thank You for your time and considerations,
> Sincerely,
> Atit
>
> On Thu, Feb 12, 2009 at 4:07 PM, Arne Roomann-Kurrik
> <api.kur...@google.com>wrote:

Atit Thekdi

unread,
Feb 12, 2009, 8:38:26 PM2/12/09
to opensocial-cl...@googlegroups.com
Thanks a lot Arne, Appreciate a lot :)

Yes, I am not interested in crawling all of the data. I probably have 100 some friends common on both the networks. If I can melodramatically match these profile, I am going to assume that it scales. NO comment on precision or recall, Yet.

However, I already tried the link that you suggested me to generate before sending the previous email. This link always directs to their Orkut home page :(. I wonder if they need to have a sandbox account?

Thanks again,
Atit

Arne Roomann-Kurrik

unread,
Feb 12, 2009, 8:45:13 PM2/12/09
to opensocial-client-libraries
Oops, sorry, forgot about the whitelisting. Users will need to sign
up at http://sandbox.orkut.com/SandboxSignup.aspx before they can use
sandbox urls :( Thankfully this is now an automated process.

~Arne

On Feb 12, 5:38 pm, Atit Thekdi <thekdis...@gmail.com> wrote:
> Thanks a lot Arne, Appreciate a lot :)
>
> Yes, I am not interested in crawling all of the data. I probably have 100
> some friends common on both the networks. If I can melodramatically match
> these profile, I am going to assume that it scales. NO comment on precision
> or recall, Yet.
>
> However, I already tried the link that you suggested me to generate before
> sending the previous email. This link always directs to their Orkut home
> page :(. I wonder if they need to have a sandbox account?
>
> Thanks again,
> Atit
>
> On Thu, Feb 12, 2009 at 5:56 PM, Arne Roomann-Kurrik
> <api.kur...@google.com>wrote:

Atit Thekdi

unread,
Feb 13, 2009, 12:41:09 AM2/13/09
to opensocial-cl...@googlegroups.com
Hi Arne,

I had few friends add my application. And then I fired script consisting,

$batch->add($osapi->people->get(array('userId' => $userId, 'groupId' => '@friends', 'count' => 2000, 'fields' => array('displayName','name','age','gender','aboutMe', 'movies', 'activities'))), 'friends');

but I am still not able to get additional fields :(

Do I have to get their data while they are logged in?

Atit

Atit Thekdi

unread,
Feb 13, 2009, 2:56:57 AM2/13/09
to opensocial-cl...@googlegroups.com
Also, when I run my scrip through chrome, I get following warnings (same warning twice):

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in /home/content/a/t/h/athekdi/html/osapi/src/service/osapiActivities.php on line 80

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in /home/content/a/t/h/athekdi/html/osapi/src/service/osapiActivities.php on line 80


Chris Chabot

unread,
Feb 13, 2009, 5:40:21 AM2/13/09
to opensocial-cl...@googlegroups.com
Ps, you probably need to change the userId to your userId to be able to get your friend's details in the example:
  case 'orkut':
    $userId = '03067092798963641994'; //  <-- change that id to your id

Chris Chabot

unread,
Feb 13, 2009, 5:37:41 AM2/13/09
to opensocial-cl...@googlegroups.com
Change:
-    self::convertMediaItems(&$activity, &$array, $strictMode);
+    self::convertMediaItems($activity, $array, $strictMode);

and:
-  static private function convertMediaItems(osapiActivity $activity, Array $array, $strictMode) {
+  static private function convertMediaItems(osapiActivity &$activity, Array &$array, $strictMode) {

And those pesky warnings should go away :)

or in patch format:

Index: src/service/osapiActivities.php
===================================================================
--- src/service/osapiActivities.php    (revision 13)
+++ src/service/osapiActivities.php    (working copy)
@@ -53,7 +53,7 @@
    * @param array $array
    * @param boolean $strictMode
    */
-  static private function convertMediaItems(osapiActivity $activity, Array $array, $strictMode) {
+  static private function convertMediaItems(osapiActivity &$activity, Array &$array, $strictMode) {
     if (isset($array['mediaItems']) && count($array['mediaItems'])) {
       $mediaItems = array();
       foreach ($array['mediaItems'] as $mediaItem) {
@@ -77,7 +77,7 @@
       throw new osapiException("Missing user id in activity");
     }
     $activity = new osapiActivity($id, $userId);
-    self::convertMediaItems(&$activity, &$array, $strictMode);
+    self::convertMediaItems($activity, $array, $strictMode);
     $activityVars = get_object_vars($activity);
     foreach ($array as $key => $val) {
       if (array_key_exists($key, $activityVars)) {

SocialMatrix

unread,
Feb 13, 2009, 6:47:16 AM2/13/09
to opensocial-client-libraries
Hi Chris,

I had changed $userId. Also changed consumer key and consumer secret.
However, I had kept $test = 'orkutRest';

So that case 'orkutRest' is executed. I tried changing to $test =
'orkut'; to see if that changes anything but no help :(

I wonder what is $userId = '@me'; doing? Does that need to be changed?

Thanks Chris,


On Feb 13, 3:40 am, Chris Chabot <chab...@google.com> wrote:
> Ps, you probably need to change the userId to your userId to be able to get
> your friend's details in the example:
>   case 'orkut':
>     $userId = '03067092798963641994'; //  <-- change that id to your id
>
> On Fri, Feb 13, 2009 at 6:41 AM, Atit Thekdi <thekdis...@gmail.com> wrote:
> > Hi Arne,
>
> > I had few friends add my application. And then I fired script consisting,
>
> > $batch->add($osapi->people->get(array('userId' => $userId, 'groupId' =>
> > '@friends', 'count' => 2000, 'fields' =>
> > array('displayName','name','age','gender','aboutMe', 'movies',
> > 'activities'))), 'friends');
>
> > but I am still not able to get additional fields :(
>
> > Do I have to get their data while they are logged in?
>
> > Atit
>
> > On Thu, Feb 12, 2009 at 6:45 PM, Arne Roomann-Kurrik <
> > api.kur...@google.com> wrote:
>
> >> Oops, sorry, forgot about the whitelisting.  Users will need to sign
> >> up athttp://sandbox.orkut.com/SandboxSignup.aspxbefore they can use
> ...
>
> read more »

Chris Chabot

unread,
Feb 13, 2009, 6:57:05 AM2/13/09
to opensocial-cl...@googlegroups.com

With 3 legged OAuth there is a known user (the person who granted access) but no app id, so using '@me' is fine since that indicates the user that granted access.

On the other hand 2 legged oauth scenario does have an app id (the application who's consumer key/secret your using), but no user id, so in those cases (orkut, myspace) you need a userId to be able to perform those queries.

2 legged oauth is really intended for: http://sites.google.com/site/oauthgoog/2leggedoauth/2opensocialrestapi where you have an app, someone views the app, the app does a signed makeRequest (with the owner and viewer id part of the signed url, so known to your back-end), and you want to query the network for some additional information (the "reverse phone home" mentioned in the linked page).

Hence the test having a default of '@me' but for all 2 legged oauth cases it overrides that user id with a real id.

ps, the orkut / orkutRest is really just there to be able to test the different protocol implementations (REST and RPC), in practise the RPC is superior due to it's ability to process batched requests instead of having to do a request per batch entry, so using 'orkut' is the right way to go :)

I don't know exactly when orkut will support 3 legged oauth btw, however I do know the orkut team said it will be "soon":
http://www.mail-archive.com/opensoci...@googlegroups.com/msg05641.html

Atit Thekdi

unread,
Feb 13, 2009, 8:41:53 AM2/13/09
to opensocial-cl...@googlegroups.com
Thanks a lot Chris,

Do you think it'll be easier to achieve these additional fields about friends using javaScript application?

However, I need to store these field values in the relational database. Does javaScript allow MySQL connection? or is there any way around it?

Or would you recommend me using PHP client library and wait till Orkut goes 3-legged OAuth authentication?

Thanks again,
Atit

Chris Chabot

unread,
Feb 13, 2009, 8:49:41 AM2/13/09
to opensocial-cl...@googlegroups.com
If you add the OSDA (OpenSocial dev app) to your profile on orkut, you can explore what fields are available through the JS API:
http://osda.appspot.com/
(goto canvas view -> data viewer -> viewer -> show details)

On what technology to use, that's a bit hard to advice on without knowing what you are trying to do, if it's just about storing some of the fields that your app has access to in your database, then it's probably easiest to json encode those fields, and post it to your server using gadgets.io.makeRequest.

If your looking to create a site that imports some information from orkut, then 3 legged oauth + the restful client is the way to go

Atit Thekdi

unread,
Feb 16, 2009, 4:37:12 AM2/16/09
to opensocial-cl...@googlegroups.com
Hi,

My project is extremely simple, I don't know why I am taking so long and not able to do it.

I tried the OSDA (OpenSocial dev app), data I need is not available to me through JavaScript API.

I have about 286 friends on Orkut. I just need to get 'age','gender','aboutMe', 'movies', 'activities', 'books', 'interests', 'currentLocation', 'music', 'relationshipStatus', 'tvShows' for all of the 286 friends and store it in a MySQL database.

My defense date is approaching, I have already tested my algorithm against facebook data. Someone please show me how to get these values from Orkut. I am going to be in a big trouble otherwise.

Thank you very much for your time and apologies for too many questions,
Atit

Arne Roomann-Kurrik

unread,
Feb 17, 2009, 2:58:48 AM2/17/09
to opensocial-client-libraries
I'm happy to announce that I've just deleted the old copy of the
library and pushed a copy of this new library to SVN- it will now act
as the 'official' PHP client library that we will be supporting. The
code, as always, will be in http://opensocial-php-client.googlecode.com/svn/trunk/
and you may want to check out the README file at
http://opensocial-php-client.googlecode.com/svn/trunk/README to get
started.

I've included a couple basic examples in the
http://opensocial-php-client.googlecode.com/svn/trunk/examples/
directory. Note that these samples don't all work on all of the
supplied containers - we'll be working hard on providing and
documenting workarounds inside of the library for cases where a
container is out of spec (for example orkut expects "@viewer" as the
user ID for some operations) as well as working with the containers to
help them become more spec compliant.

The official announcement will be coming soon, but you'll obviously
notice the change now if you svn update your project checkouts (as
your old code will break). If you really need an old version of the
library, you can find what was in SVN before the switch at
http://opensocial-php-client.googlecode.com/svn/tags/release-0.2a/,
but be aware that we will no longer be developing or supporting that
version.

Thanks!
~Arne



On Feb 13, 3:57 am, Chris Chabot <chab...@google.com> wrote:
> With 3 legged OAuth there is a known user (the person who granted access)
> but no app id, so using '@me' is fine since that indicates the user that
> granted access.
>
> On the other hand 2 legged oauth scenario does have an app id (the
> application who's consumer key/secret your using), but no user id, so in
> those cases (orkut, myspace) you need a userId to be able to perform those
> queries.
>
> 2 legged oauth is really intended for:http://sites.google.com/site/oauthgoog/2leggedoauth/2opensocialrestapiwhere
> you have an app, someone views the app, the app does a signed makeRequest
> (with the owner and viewer id part of the signed url, so known to your
> back-end), and you want to query the network for some additional information
> (the "reverse phone home" mentioned in the linked page).
>
> Hence the test having a default of '@me' but for all 2 legged oauth cases it
> overrides that user id with a real id.
>
> ps, the orkut / orkutRest is really just there to be able to test the
> different protocol implementations (REST and RPC), in practise the RPC is
> superior due to it's ability to process batched requests instead of having
> to do a request per batch entry, so using 'orkut' is the right way to go :)
>
> I don't know exactly when orkut will support 3 legged oauth btw, however I
> do know the orkut team said it will be "soon":http://www.mail-archive.com/opensoci...@googlegroups.com/msg0564...
> > > >> up athttp://sandbox.orkut.com/SandboxSignup.aspxbeforethey can use
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages