Hi Andre,

Looking at your code,

>> function postActivity(destino,postdata){

postdata won't be available in the callback to gadgets.io.makeRequest. Check
the documentation of gadgets.io.makeRequest.

And here is sample code, please cut paste it in Opensocial Dev App and run.

--
function onActivityPosted(data) {
  if (data.hadError()) {
    alert("There was a problem: " + data.getErrorMessage());
  } else {
    output("The activity was posted successfully.");
  }
};

function postActivity(title, body) {
  var data = {};
  data[opensocial.Activity.Field.TITLE] = title;
  data[opensocial.Activity.Field.BODY] = body;
  var activity = opensocial.newActivity(data);
  opensocial.requestCreateActivity(
      activity,
      opensocial.CreateActivityPriority.HIGH,
      onActivityPosted
  );
};

postActivity("This is a sample activity", "This is an activity body");
--

Hope that helps.

Thanks,
Sachin

2010/5/17 André Lima <azdr3mi...@gmail.com>

> if anyone can see anything that is incorrect on the code,please say
> it...i can't test it right now,so any suggestions are welcome...
>
> On 17 maio, 13:23, André Lima <azdr3mi...@gmail.com> wrote:
> > well,I made some changes on my code...here is how it looks now...but
> > I'm not sure if the implementation is right...the gadget requests a
> > page and get the values of that page that was submitted...then show it
> > at the updates..this is the code that matters:
> >        <![CDATA[
> >       <b id =  "ativ"></b>
> >       ]]>
> >      </Content
> >
> >         <Content type="html" view="canvas">
> >            <![CDATA[
> >                 <html>
> >
> >                         <head>
> >
> >                         <script type="text/javascript">
> >
> >                         var globalView =
> > gadgets.views.getCurrentView().getName();
> >
> >                         function init()
> >                         {
> >                                 loadFriends();
> >                                 requisitaPagina("xxxz");
> >                         }
> >
> >                         function requisitaPagina(page)
> >                         {
> >                                 var params={}
> >
> params[gadgets.io.RequestParameters.CONTENT_TYPE] =
> > gadgets.io.ContentType.TEXT;
> >                                 gadgets.io.makeRequest(page,
> onPaginaCallback,params);
> >                         }
> >
> >                         // callback retornado a partir da funcao acima
> >                         function onPaginaCallback(ret)
> >                         {
> >                                 var x = document.getElementById("teste");
> >                                 x.innerHTML = ret.text;
> >                         }
> >                     function loadFriends() {
> >   var req = opensocial.newDataRequest();
> >
> > req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER),
> > 'viewer');
> >
> >   var viewerFriends = opensocial.newIdSpec({ "userId" : "VIEWER",
> > "groupId" : "FRIENDS" });
> >   var opt_params = {};
> >   opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 100;
> >   req.add(req.newFetchPeopleRequest(viewerFriends, opt_params),
> > 'viewerFriends');
> >
> > }
> >
> >                         function enviaPost()
> >                         {
> >
> >                                 var destino = "...";
> >
> >                                 var value =
> > document.getElementById("id_product_value").value;
> >                                 var telefone =
> document.getElementById("id_phone1").value;
> >                                 var username =
> document.getElementById("id_username").value;
> >                                 var password =
> document.getElementById("id_password").value;
> >                                 var carrier =
> document.getElementById("id_mobile_carrier");
> >                                 carrier =
> carrier.options[carrier.selectedIndex].value;
> >
> >                                 var postdata = {phone1: telefone, phone2:
> telefone,
> > mobile_carrier: carrier, username:username,
> > password:password,product_value:value};
> >                                 postdata =
> gadgets.io.encodeValues(postdata);
> >
> >                                 alert('postdata =' + postdata);
> >
> >                                 var params = {};
> >
> params[gadgets.io.RequestParameters.METHOD] =
> > gadgets.io.MethodType.POST;
> >
> params[gadgets.io.RequestParameters.POST_DATA]= postdata;
> >
> gadgets.io.makeRequest(destino,postActivity,params);
> >
> >                         }
> >
> >   function postActivity(destino,postdata){
> >      var title = 'comprou ' + postdata[product_value] 'reais de
> > recarga de operadora ' + postdata[mobile_carrier];
> >   var params = {};
> >   params[opensocial.Activity.Field.TITLE] = title;
> >   var activity = opensocial.newActivity(params);
> >   opensocial.requestCreateActivity(activity,
> > opensocial.CreateActivityPriority.HIGH,callbackAtividade);}
> >
> >   function callbackAtividade(ret)
> >                     {
> >                         var z = document.getElementById("ativ");
> >                         z.innerHTML = ret.text;
> >                     }
> > gadgets.util.registerOnLoadHandler(init);
> >                                         </script>
> >                 </head>
> >                 <body>
> >                         <div id="post"><input type="submit"
> onclick="enviaPost()"
> > value="ENVIAR POST"></div>
> >                         <div id="teste">conteudo</div>
> >                                 </body>
> >         </html>
> >                 ]]>
> >         </Content>
> >   </Module>
> >
> > On 11 maio, 09:46, André Lima <azdr3mi...@gmail.com> wrote:
> >
> >
> >
> > > Hello everybody...I am trying to make an activity on my aplication,but
> > > it don't work...i get some values of a html page that is outside of
> > > xml...there is no return,no message of update is show...i don't what
> > > is wrong,i will post the code here...maybe you can help me:
> > > <?xml version="1.0" encoding="UTF-8" ?>
> > > <Module>
> > >     <ModulePrefs title="..."
> > >     directory_title="..."
> > >     description="...."
> > >    screenshot="..."
> > >     title_url="http://www.counttonine.com";
> > >     author="Ted Mosby"
> > >     author_email="..."
> > >     author_link="http://www.counttonine.com/aboutUs.htm";
> > >     author_location="..."
> > >     author_affiliation="Count to Nine"
> > >     height="370"
> > >     scrolling="false"
> > >     author_aboutme="..."
> > >     author_photo="..."
> > >     author_quote="..."
> > >     thumbnail="...">
> > >      <Preload href = "http://netmony.marestelecom.net/gadget/
> > > recharge/"/>
> > >      <Require feature = "opensocial-0.8"/>
> > > </ModulePrefs>
> > >  <Content type="url" href="http://netmony.marestelecom.net/gadget/
> > > recharge/">
> >
> > > <![CDATA[
> > >  <script type = "text/javascript">
> > > var globalFriends = {};
> > > function callbackCustom(responseItem){
> > > if(responseItem.hadError()){
> > >  if responseItem.getErrorCode(){ ==
> > > opensocial.ResponseItem.ERROR.NOT_IMPLEMENTED){
> > > alert("not implemented");}else{
> >
> > > alert("success!" + rensponseItem.getErrorCode());}
> >
> > > var returnData = rensponseItem.getData();
> >
> > > }
> >
> > >  function postActivity(text){
> > >    var url = 'http://netmony.marestelecom.net/gadget/recharge/';
> > >    opt_params = {};
> > >   opt_params[gadgets.io.RequestParameters.CONTENT_TYPE] =
> > > gadgets.io.ContentType.TEXT;
> > >    gadgets.io.makeRequest(url,opt_params,callback);
> > >     var price = document.getElementById('id_price');
> > >        url = gadgets.io.encodeValues(price);
> > >   var text =  'Compra de recarga.' +
> > > globalFriends.getById(viewerFriends).getDisplayName() 'comprou' +
> > > price.value 'reais de recarga de operadora Y.';
> > >   var params = {};
> > >   params[opensocial.Activity.Field.TITLE] = text;
> > >   var activity = opensocial.newActivity(params);
> >
> > >
> opensocial.requestCreateActivity(opensocial,opensocial.CreateActivityPriority.HIGH,callbackCustom);
> > >   }
> > >         function loadFriends() {
> > >           var req = opensocial.newDataRequest();
> > >          req.add(req.newFetchPersonRequest("VIEWER"), 'viewer');
> >
> > >    var viewerFriends = opensocial.newIdSpec({ "userId" : "VIEWER",
> > > "groupId" : "FRIENDS" });
> > >                                         var opt_params = {};
> > >
> opt_params[opensocial.DataRequest.PeopleRequestFields.MAX] = 100;
> > >          req.add(req.newFetchPeopleRequest(viewerFriends, opt_params),
> > > 'viewerFriends');
> > >           var viewer = opensocial.newIdSpec({ "userId" : "VIEWER" });
> > >         req.send(postActivity);}
> >
> > >     function init(){
> > > loadFriends();}
> >
> > > gadgets.util.registerOnLoadHandler(init);
> > > </script>
> > >   ]]>
> > > </Content>
> > > </Module>
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Orkut Developer Forum" group.
> > > To post to this group, send email to opensocial-orkut@googlegroups.com
> .
> > > To unsubscribe from this group, send email to
> opensocial-orkut+unsubscr...@googlegroups.com<opensocial-orkut%2bunsubscr...@googlegroups.com>
> .
> > > For more options, visit this group athttp://
> groups.google.com/group/opensocial-orkut?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Orkut Developer Forum" group.
> > To post to this group, send email to opensocial-or...@googlegroups.com.
> > To unsubscribe from this group, send email to
> opensocial-orkut+unsubscr...@googlegroups.com<opensocial-orkut%2bunsubscr...@googlegroups.com>
> .
> > For more options, visit this group athttp://
> groups.google.com/group/opensocial-orkut?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Orkut Developer Forum" group.
> To post to this group, send email to opensocial-or...@googlegroups.com.
> To unsubscribe from this group, send email to
> opensocial-orkut+unsubscr...@googlegroups.com<opensocial-orkut%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/opensocial-orkut?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Orkut Developer Forum" group.
To post to this group, send email to opensocial-or...@googlegroups.com.
To unsubscribe from this group, send email to 
opensocial-orkut+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/opensocial-orkut?hl=en.

Reply via email to