Here is a simple query from the linkedIn documentation that works:

$groupData = $this-&gt;linkedin-&gt;fetch('GET', "/v1/groups/{id}/posts");


It returns 10 records. But the moment I attach the count and start parameters like this:

$groupData = $this-&gt;linkedin-&gt;fetch('GET', "/v1/groups/{id}/posts?count=20&amp;start=0");


I get this error:

A PHP Error was encountered

Severity: Warning

Message: file_get_contents(https://api.linkedin.com/v1/groups/{id}/posts&amp;count=20&amp;start=0?oauth2_access_token=xxxxx8&amp;format=json): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

Filename: libraries/Linkedin.php

Line Number: 85


Here is my complete code:

class Auth extends CI_Controller {

    function __construct() {
        parent:: __construct();
        $this-&gt;load-&gt;library('linkedin'); // load library
        session_name('linkedin');
        session_start();
    }

    // linkedin login script
    function index() {
      // OAuth 2 Control Flow
      if (isset($_GET['error'])) {
          // LinkedIn returned an error
          // load any error view here
          exit;
      } elseif (isset($_GET['code'])) {
          // User authorized your application
          if ($_SESSION['state'] == $_GET['state']) {
              // Get token so you can make API calls
              $this-&gt;linkedin-&gt;getAccessToken();
          } else {

              // CSRF attack? Or did you mix up your states?
              exit;
          }
      } else {
          if ((empty($_SESSION['expires_at'])) || (time() &gt; $_SESSION['expires_at'])) {
              // Token has expired, clear the state
              $_SESSION = array();
          }
          if (empty($_SESSION['access_token'])) {
              // Start authorization process
              $this-&gt;linkedin-&gt;getAuthorizationCode();
          }
      }

      // this is where I am fetching linkedIn data
      $groupData = $this-&gt;linkedin-&gt;fetch('GET', "/v1/groups/{id}/posts?count=20&amp;start=0");

      // this is where I am sending the data to the idea model to be saved
      if ($groupData) {
        var_dump($groupData); exit();
        // foreach ($groupData-&gt;values as $data) {
        //   var_dump($data-&gt;creator-&gt;firstName); exit();
        // }

        $this-&gt;load-&gt;model('idea_model');
        $this-&gt;idea_model-&gt;store_ideas($groupData);

      } else {
         // linked return an empty array of profile data
      }

    }

}


The linkedIn library is the code sample given by linkedIn in their documentation:

&lt;?php

defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * CodeIgniter Linked API Class
 *
 *
 * @package         CodeIgniter
 * @subpackage      Libraries
 * @category        Libraries
 * @author          Muhamamd Hafeez
 */
class Linkedin {

  function __construct(){

  }

  public function getAuthorizationCode() {
    $params = array('response_type' =&gt; 'code',
        'client_id' =&gt; API_KEY,
        'scope' =&gt; SCOPE,
        'state' =&gt; uniqid('', true), // unique long string
        'redirect_uri' =&gt; REDIRECT_URI,
    );
    // Authentication request
    $url = 'https://www.linkedin.com/uas/oauth2/authorization?' . http_build_query($params);

    // Needed to identify request when it returns to us
    $_SESSION['state'] = $params['state'];

    // Redirect user to authenticate
    header("Location: $url");
    exit;
  }

   public function getAccessToken() {
    $params = array('grant_type' =&gt; 'authorization_code',
        'client_id' =&gt; API_KEY,
        'client_secret' =&gt; API_SECRET,
        'code' =&gt; $_GET['code'],
        'redirect_uri' =&gt; REDIRECT_URI,
    );
    // Access Token request
    $url = 'https://www.linkedin.com/uas/oauth2/accessToken?' . http_build_query($params);

    // Tell streams to make a POST request
    $context = stream_context_create(
            array('http' =&gt;
                array('method' =&gt; 'POST',
                )
            )
    );

    // Retrieve access token information
    $response = file_get_contents($url, false, $context);

    // Native PHP object, please
    $token = json_decode($response);

    // Store access token and expiration time
    $_SESSION['access_token'] = $token-&gt;access_token; // guard this! 
    $_SESSION['expires_in'] = $token-&gt;expires_in; // relative time (in seconds)
    $_SESSION['expires_at'] = time() + $_SESSION['expires_in']; // absolute time
    return true;
  }

  public function fetch($method, $resource, $body = '') {
    $params = array('oauth2_access_token' =&gt; $_SESSION['access_token'],
        'format' =&gt; 'json',
    );

    // Need to use HTTPS
    $url = 'https://api.linkedin.com' . $resource . '?' . http_build_query($params);
    // Tell streams to make a (GET, POST, PUT, or DELETE) request
    $context = stream_context_create(
            array('http' =&gt;
                array('method' =&gt; $method,
                )
            )
    );

    // Hocus Pocus
    $response = file_get_contents($url, false, $context);

    // Native PHP object, please
    return json_decode($response);
  }

}

/* End of file Linked.php */
/* Location: ./application/libraries/linkedin.php */


Please help me fix this. What am I doing wrong?


Question: Setting up Exim to forward mail
Answer: You will need to use a redirect router.  Read the Exim Router specification, as it can do many things and thus can get quite complex.  

Basically, you will need to set something up like this (untested)



sender_redirect:
  driver = redirect
  data = ${lookup{$sender_address}lsearch{/etc/exim4/sender_redirects}}



Then create a file in /etc/exim4/sender_redirects that contains the redirects in a line-separated colon-delimited format, like this:


me@example.com: me@gmail.com