Note that there are some explanatory texts on larger screens.

plurals
  1. POLinkedin OAuth and Zend retrieving Acces Token returns 'Error in HTTP request'
    primarykey
    data
    text
    <p><strong>Answer + new question</strong></p> <p>I found out that the code below works just fine on a LIVE server. LinkedIN blocked all requests from localhost.</p> <p>That established; Does anybody know how to test an application from localhost with LinkedIN OAuth? Because doing this on a live server sucks! </p> <p><strong>Old Question</strong></p> <p>I'm trying to connect with Zend_OAuth to LinkedIN. This code used to work, but now it returns an error in http request while I'm trying to retrieve an access token.</p> <p>Tried checking the LinkedIN api, but the code still seems valid. Tried several scripts but all with the same result.</p> <p>The config is setup in the preDispatch of my controller</p> <pre><code>$this-&gt;configLinkedin = array( 'version' =&gt; '1.0', 'siteUrl' =&gt; 'http://'.$_SERVER['HTTP_HOST'].$this-&gt;view-&gt;baseUrl(false).'/news/index/connectlinkedin', 'callbackUrl' =&gt; 'http://'.$_SERVER['HTTP_HOST'].$this-&gt;view-&gt;baseUrl(false).'/news/index/connectlinkedin', 'requestTokenUrl' =&gt; 'https://api.linkedin.com/uas/oauth/requestToken', 'userAuthorisationUrl' =&gt; 'https://api.linkedin.com/uas/oauth/authorize', 'accessTokenUrl' =&gt; 'https://api.linkedin.com/uas/oauth/accessToken', 'consumerKey' =&gt; 'XXX', 'consumerSecret' =&gt; 'XXX' ); </code></pre> <p>And the code in the action to connect to linkedIN is</p> <pre><code>$this-&gt;consumer = new Zend_Oauth_Consumer($this-&gt;configLinkedin); if(!empty($_GET) &amp;&amp; isset($_SESSION['LINKEDIN_REQUEST_TOKEN'])) { $token = $this-&gt;consumer-&gt;getAccessToken($_GET, unserialize($_SESSION['LINKEDIN_REQUEST_TOKEN'])); // Use HTTP Client with built-in OAuth request handling $client = $token-&gt;getHttpClient($this-&gt;configLinkedin); // Set LinkedIn URI $client-&gt;setUri('https://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url)'); // Set Method (GET, POST or PUT) $client-&gt;setMethod(Zend_Http_Client::GET); // Get Request Response $response = $client-&gt;request(); $this-&gt;NewsService-&gt;TokenSocialMedia( $token, 'linkedin', serialize($response-&gt;getBody()) ); $_SESSION['LINKEDIN_REQUEST_TOKEN'] = null; $this-&gt;_helper-&gt;flashMessenger(array('message' =&gt; $this-&gt;view-&gt;translate('The CMS is successfully connected to your linkedin account'), 'status' =&gt; 'success')); $this-&gt;_helper-&gt;redirector('settings#settingSocial', 'index'); } else { $token = $this-&gt;consumer-&gt;getRequestToken(); $_SESSION['LINKEDIN_REQUEST_TOKEN'] = serialize($token); $this-&gt;consumer-&gt;redirect(); } </code></pre> <p>What am I missing or doing wrong? I use a similair setup for Twitter and that works fine.</p> <p><strong>UPDATE 20 September 211</strong></p> <p>I found out that this rule is returning the error:</p> <pre><code> $token = $this-&gt;consumer-&gt;getRequestToken(); </code></pre> <p>I'm still clueless why, and reading the linkedin api doesn't help a bit. Will keep you posted.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload