I am trying to create content from a cron job with a custom node type that contains just a title and body; the content type is mycontent (for argument sake).
I am trying to use the Entity API module because apparently it is supposed to be simpler.
Working from examples, I wrote the following code.
$values = array(
'type' => 'mycontent',
'uid' => $user->uid
);
$entity = entity_create('node', $values);
$ewrapper = entity_metadata_wrapper('node', $entity);
$ewrapper->title->set('My Title');
Clearly I am missing something here because I get an exception (EntityMetadataWrapperException: Unknown data property title).
So I changed it to the following.
$values = array(
'type' => 'mycontent',
'uid' => $user->uid
);
$entity = entity_create('mycontent', $values);
$ewrapper = entity_metadata_wrapper('mycontent', $entity);
$ewrapper->title->set('My Title');
Now I get a different error, an obtuse Invalid data value given.
Why cannot I get the Entity API module to work as advertised?
The current user in this case is user 1, not the anonymous user. If I add the content using Drupal standard functions, it works. So I know I am not having a permission issue.
I looked at this example, to write my code, and then proceeded to google a lot.