Take a look on following topics where you can find some examples:
http://ez.no/developer/forum/developer/dynamically_creating_multiple_locations
http://ez.no/developer/forum/install_configuration/how_to_create_ezcontentobject_programmatically/re_how_to_create_ezcontentobject_programmatically
http://ez.no/developer/forum/developer/how_can_we_create_content_objects_from_code/re_how_can_we_create_content_objects_from_code__4 http://ez.no/developer/forum/developer/creating_a_simple_content_object_via_php/re_creating_a_simple_content_object_via_php__12