carrot.postAction

Thanks!

Ok so ‘object_type’ would be ‘level’ I think based on your code. The specific “level_x” is a specific instance of the ‘level’ object type.

It’s kind of like the difference between a class, and an instance of a class.

Does that help clarify things?

Alright, so I tried changing it to level and ended up with this code, but it’s still not posting:

carrot.postAction('complete', nil, nil, {object\_type='level', title='Some title stuff that is about this long right now', description='I just reached level '..level..'.', image\_url='\<imgurl\>'})

On our Carrot page, our unique id is “level”  and the code we get from the “Code” button for Corona SDK is carrot.postAction(“complete”, “level”).

Not sure what could be messing about?

Ahh ok.

So what is the object type of “level” then? On that page it should say in the title and the url. 

For example (one of our test apps) the URL is https://gocarrot.com/apps/695835443787890/prize

So the object type is ‘prize’ and then that’s where we have the instances of different prizes.

I see, the title at the top of the page says “Levels” but the url says “level”. I’ll try use both Levels and levels as the object_type now and see if that works.

Hmmmm, it should be “level” in that case. That is strange.

If you go to https://facebook.com/me/allactivity do the posts show up?

The open graph objects don’t show up to you on your wall immediately.

Yeah that’s the page I’m double checking against and nothing has popped up there thus far.

Edit: Just tested ‘levels’ but it once again didn’t post anything. This is truly strange because it works perfectly when we use the normal carrot.postAction(action, object) code.

Oh I know what is going wrong. What is your app id? I need to enable dynamic posts for the app.

Ah, is this needed for all apps? Or should there be a button that we must click to enable the dynamic posts? Fired you the app id over pm :slight_smile: Thanks again for all the help.

Oh yikes. I know what is going wrong. We changed this since the sample code I posted up top.

So what you want to do is go to your levels and make an object and check the box “Use as Template”.

Let me whip up a new sample.

Awesome, cheers.

Ok, so I think that it needs to look like this:

carrot.postAction("ACTION\_ID", nil, nil, { object\_type = "OBJECT\_TYPE", title = "New Object Title", description = "New Object Description", template = "TEMPLATE\_ID", image\_url = "http://placekitten.com/512/512"})&nbsp;

And that new parameter ‘template’ needs to be the identifier of the instance that you said “Use as Template”.

Then in the web-tool, put “{{title}}” for the title, “{{description}}” for the description etc.

You can also add more data and such, so for example the description in the web tool could be: “I just reached level {{level}}!” and you would pass along level = “5” in the call, if that makes sense.

Hmm nope, still nothing, using this code right now:

carrot.postAction('complete', nil, nil, {object\_type='level', template='level', title='Some title stuff that is about this long right now', description='I just reached level '..level..'.', image\_url='\<imgurl\>'})

And the template value being the unique id of the instance I created inside “Levels”. The value that is preceded by a ‘#’ in the web-tool. But still using this it’s not posting for some reason.

Edit: Also added {{title}} and {{description}} as the web-tool’s title and description but no success…

Edit2: Tried changing the template id to be different from the object_type value but no success there either… It’s really strange since everything otherwise works just fine…

Ah I totally did that wrong. Sorry, hard to keep the SDKs all in my head (re-write is in progress to standardize them)

It should look like this:

carrot.postAction('complete','level', nil, { title = "New Object Title", description = "New Object Description", image\_url = "http://placekitten.com/512/512"}) 

This makes it similar to a standard ‘postAction’ only passing along the data for the template.

It’s possible that it will give an error “objectProperties must contain an entry for ‘object_type’.” and if that’s the case, simply put in a dummy value for ‘object_type’.

Thanks, will test that out asap.

Edit: UGH finally!! The last issue seems to have been on my end where I for some reason had swapped the carrot app secret with the app key in the carrot.init() call. Switched it back now and using the last sample quoted in this post it works like a charm! Thanks a lot again for the help!!  :slight_smile:

Awesome! I’m very glad.

Sorry for the confusion earlier. In future versions the Docs and SDK will be more clear for how it is intended to be used.

Let me know if you have any other issues.

Cheers!