$field = array(
'field_name' => 'demo_textfield',
'type' => 'text',
);
field_create_field($field);
$instance = array(
'field_name' => 'demo_textfield',
'entity_type' => 'node',
'bundle' => 'article',
'label' => t('Demo texfield'),
'description' => t('Just a demo textfield'),
'widget' => array(
'type' => 'text_textfield',
),
);
field_create_instance($instance);