How to get a list of entities programmatically? I wrote custom rules action to get a list of active simplenews subscribers, but I can not process it with "loop" cycle. Action should get list of active simplenews subscribers ("entity_fetched" array). Then I pass it to "loop" for processing (and to get "list-item" variable) and there are no errors. But when I try to set status message (add action - system - set message) with "list-item:uid", system says: "Data selector list-item:uid for parameter message is invalid". More, I can not select "list-item" token at all. I think, there are some mistakes when the code returns "entity_fetched" array. There is my code:

&lt;?php

   function custom_simplenews_rules_rules_action_info() {
      $actions = array(
         'custom_simplenews_rules_actions_get_subscribers' =&gt; array(
            'label' =&gt; t('Get subscribers by Simplenews Newsletters category'),
            'group' =&gt; t('Custom'),
            'parameter' =&gt; array(
               'category' =&gt; array(
                  'type' =&gt; 'text',
                  'label' =&gt; t('Category'),
                  'options list' =&gt; 'custom_simplenews_rules_options_list',
                  'description' =&gt; t('Specify category to select users from'),
               ),
            ),
            'provides' =&gt; array(
               'entity_fetched' =&gt; array('type' =&gt; 'list', 'label' =&gt; t('Fetched entity')),
            ),
         ),
      );

      return $actions;
   }

   function custom_simplenews_rules_options_list() {
      $taxonomy_vids_objects = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE module = :module", array(':module' =&gt; 'simplenews'))-&gt;fetchAll();

      $taxonomy_vids_array = array();
      foreach ($taxonomy_vids_objects as $value) {
         $taxonomy_vids_array[$value-&gt;vid] = $value-&gt;vid;
      }

      $taxonomy_vids = implode(',', $taxonomy_vids_array);
      $taxonomy_tids = db_query("SELECT tid, name FROM {taxonomy_term_data} WHERE vid IN (:vids)", array(':vids' =&gt; $taxonomy_vids))-&gt;fetchAll();

      $categories = array();
      foreach ($taxonomy_tids as $value) {
         $categories[$value-&gt;tid] = $value-&gt;name;
      }

      return $categories;
   }

   function custom_simplenews_rules_actions_get_subscribers(&amp;$category) {
      $categories_array = array();
      foreach ($category as $key =&gt; $value) {
         $categories_array[$key] = $key;
      }

      $categories = implode(',', $categories_array);
      $subscribers_snids = db_query("SELECT snid FROM {simplenews_subscription} WHERE vid IN (:vid)", array(':vid' =&gt; array_keys($categories)))-&gt;fetchAll();

      $subscribers_uids = array();
      foreach ($subscribers_snids as $value) {
         $subscribers_uids[$value-&gt;snid] = db_query("SELECT uid FROM {simplenews_subscriber} WHERE snid = :snid AND activated = 1", array(':snid' =&gt; $value-&gt;snid))-&gt;fetchAll();
      }

      $users_list = entity_load('user', $subscribers_uids);

      return array('entity_fetched' =&gt; array_values($users_list));
   }


Can not determine what I've done wrong. Please help!
From the very beginning, I went the wrong way. The problem is solved with the vievs_rules module. I made a view of simplenews subscribers, with relations with subscriber:email and subscription:category, then added filters by term (subscription category), by user (active or not) and subscription status. I used a user entity as resulting variable. Then I just imported the view into views loop (Rules UI) and voila!

Very thanks to @Pierre.Vriens for pointing me to views_rules