title: Flagging/hiding posts twitter api 1.1 php
body: <p>I am calling a php file from an angular front end, and then showing a timeline of tweets.</p>
  
  <p>The php file checks for tweets every ten minutes, and after this time updates a json file which is then called from angular. I want to create an admin ability to flag/hide posts from appearing in the timeline. Does anyone have any advice on how this should be done?</p>
  
  <p>Should it be done by making a <code>POST</code> request from Angular to the php file to set a flag on a tweet? If so how would this be done?</p>
  
  <p>My code looks like this.</p>
  
  <p><strong>php</strong></p>
  
  <pre><code>&lt;?php
  require_once('twitter_proxy.php');
  // Twitter OAuth Config options
  $oauth_access_token = '*****';
  $oauth_access_token_secret = '*****';
  $consumer_key = '*****';
  $consumer_secret = '*****';
  $user_id = '*****';
  $screen_name = 'StackOverflow';
  $count = 5;
  $twitter_url = 'statuses/user_timeline.json';
  $twitter_url .= '?user_id=' . $user_id;
  $twitter_url .= '&amp;screen_name=' . $screen_name;
  $twitter_url .= '&amp;count=' . $count;
  // Create a Twitter Proxy object from our twitter_proxy.php class
  $twitter_proxy = new TwitterProxy(
      $oauth_access_token,            // 'Access token' on https://apps.twitter.com
      $oauth_access_token_secret,     // 'Access token secret' on https://apps.twitter.com
      $consumer_key,                  // 'API key' on https://apps.twitter.com
      $consumer_secret,               // 'API secret' on https://apps.twitter.com
      $user_id,                       // User id (http://gettwitterid.com/)
      $screen_name,                   // Twitter handle
      $count                          // The number of tweets to pull out
  );
  
  function checkForUpdates($twitter_proxy, $twitter_url) {
      $tweets = $twitter_proxy-&gt;get($twitter_url);
      $data = array ('twitter_result' =&gt; $tweets, 'timestamp' =&gt; time());
      file_put_contents('twitter_result.json', json_encode($data));
  }
  
  //check if the file exists
  if(!file_exists('twitter_result.json')) {
      //Invoke the get method to retrieve results via a cURL request
      //and create a file with timestamp containing tweets
      checkForUpdates($twitter_proxy, $twitter_url);
  
  }else {
      //if file exists check it has not been updated in 10 minutes
      //if not update the tweets and timestamp
      $data = json_decode(file_get_contents('twitter_result.json'));
      if ($data-&gt;{"timestamp"} &gt; (time() - 10 * 60)) {
          checkForUpdates($twitter_proxy, $twitter_url);
      }
  }
  </code></pre>
  
  <p><strong>factory.js</strong></p>
  
  <pre><code>app.factory('testMedia', ['$http', function($http){
      return {
          updateTwitter: function() {
              return $http({
                  url: 'get_tweets.php',
                  method: 'GET'
              })
          },
          fetchTwitter: function() {
              return $http({
                  url: 'twitter_result.json',
                  method: 'GET'
              })
          }
      }
  }]);
  </code></pre>
  
  <p><strong>twitterCtrl.js</strong></p>
  
  <pre><code>app.controller("twitterCtrl", ["$routeParams", "testMedia", function ($routeParams, socialMedia) {
      twitterCtrl = this;
      this.twitterPosts = [];   
  
      testMedia.updateTwitter()
      .then(function(){
          testMedia.fetchTwitter()
          .then(function(response){
              var result = JSON.parse(response.data.twitter_result);
              for(var i = 0; i &lt; result.length; i++){
                  result[i].created_at = new Date(result[i].created_at);
                  twitterCtrl.twitterPosts.push(result[i]);
              }      
          })
      });
  }]);
  </code></pre>