MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

Getting BAD_REQUEST when I request photos

Last post 06-09-2008 6:26 AM by Eddie. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-05-2008 6:13 PM

    • JC
    • Top 100 Contributor
    • Joined on 06-02-2008
    • Posts 41

    Getting BAD_REQUEST when I request photos

    I have an application in which I'm trying to accomplish the following: 

    1) Display thumbnails of the application owner and all of his friends.

    2) When a user clicks on one of the thumbnails, he is shown a list of all photos for that user.  (I'm not sure whether you can even access friend's photos, but I haven't gotten that far yet).

     So the first part works great.  Here are some code snippets:

     This method works to get the the container initialized.  It then calls getOwnerAndFriends().

               public function init():void {
                  var osToken:String = Application.application.parameters.opensocial_token;
                  var osSurfaceName:String = Application.application.parameters.opensocial_surface;
                  MySpaceContainer.instance.init(osToken, osSurfaceName);
                   getOwnerAndFriends();
               }

    The getOwnerAndFriends method is very vanilla and works

            public function getOwnerAndFriends():void {
               //DataRequest returned by newDataRequest actually of type MSDataRequest.
               //MSDataRequest includes functions declared in OpenSocial.DataRequest as well as
               //the MySpace extensions.
               var dr:MSDataRequest = opensocial.newDataRequest() as MyOpenSpace.MSDataRequest;
               dr.add(dr.newFetchPersonRequest('OWNER'), 'Owner');
               dr.add(dr.newFetchPeopleRequest('OWNER_FRIENDS'), 'OwnerFriends');
               dr.send(onLoadPeople);
            }

    The callback "onLoadPeople" puts the owner and his friends into class variables:

            public function onLoadPeople(dataResponse:DataResponse):void {
               person = opensocial.Person(dataResponse.get('Owner').getData());
               friends = opensocial.Collection(dataResponse.get('OwnerFriends').getData());
              
            } 

     Then, the application works with the person and friends variables to display them within components.  The components have a 'click' event which ends up calling the getPhotos method:

            public function getPhotos(friend:Object):void {
                theFriend = friend;
                var dr:MSDataRequest = opensocial.newDataRequest() as MyOpenSpace.MSDataRequest;
                dr.add(dr.newFetchPhotosRequest(friend.getField("ID"), params), 'Photos');
                dr.send(onLoadPhotos);
            }

     When I look at the value of friend.getField(ID), it is what I would expect.  It is the ID of the friend or owner that I have clicked on.  So I think I'm creating the request correctly.  When I look at examples over in the javascript forums, it seems like I'm doing the same thing.  Oh, by the way, "params" is declared in the class as

            private static var params:Object = {};

     

    So finally, when the callback, onLoadPhotos is called, I just do what is shown below, and it says "BAD_REQUEST" when I run it whether I pass in myself or one of my friends.

              private function onLoadPhotos(dataResponse:DataResponse):void {
                    Alert.show("Let's see what we got: " + dataResponse.get('Photos').getErrorCode());

              } 

     I appreciate any advice.

    Thanks,

    --JC 

    Filed under: , ,
  • 06-05-2008 8:07 PM In reply to

    • JC
    • Top 100 Contributor
    • Joined on 06-02-2008
    • Posts 41

    Re: Getting BAD_REQUEST when I request photos

     So one of the things that was iffy about the code above is that my newFetchPhotoRequest was using a passed in ID of the owner or owner friend.  I changed it so that it now reads

        dr.add(dr.newFetchPhotosRequest('OWNER', params), 'Photos');

     And that got me beyond the BAD_REQUEST issue.  Then I was getting the error "This app does not have access to photos" which I've seen covered in other posts.

     Unfortunately, when I try to make a call to 

            opensocial.requestPermission(["accesstopublicvideosphotos"],
                        "Because we need your photos!",
                        checkPhotoPermissionResponse);

     Nothing happens.  Nothing at all happens.

  • 06-05-2008 8:27 PM In reply to

    • JC
    • Top 100 Contributor
    • Joined on 06-02-2008
    • Posts 41

    Re: Getting BAD_REQUEST when I request photos

     Ha!  So I just looked through the AS3Lib source and discovered that the reason it doesn't do anything is that it is not implemented.  Now I guess I'm going to look and see if it's possible to do this via the REST api.  If anyone wants to jump in and save me a few hours, I'd deeply appreciate it.

  • 06-05-2008 10:03 PM In reply to

    • JC
    • Top 100 Contributor
    • Joined on 06-02-2008
    • Posts 41

    Re: Getting BAD_REQUEST when I request photos

    I'm carrying on a conversation with myself, but hopefully this will help someone else.  So I found out that I can update my application's ability to access photos AFTER install by updating it in the application manager.  This is a start, but since these properties are not available at app install time, I will still need to be able to allow a user to do it on the fly because they won't know to go update their app properties in the app manager. 

  • 06-09-2008 6:26 AM In reply to

    Re: Getting BAD_REQUEST when I request photos

    Hey JC,

    Flash cannot do it on the fly until the iframe change comes in.

    If the app settings are not set you'll have to put out a mesage telling the user what to do.

    You're lucky myspace threw the photo permission changes in one night and killed two of my apps and upto 13000 users in one foul swoop - I did not have a good day that day....

    I've not seen an opensocial or myspace call to get friends photos though I do see users can now block this....

    Eddie 

Page 1 of 1 (5 items)