Note that there are some explanatory texts on larger screens.

plurals
  1. POLinkedIn integration - Establish a requestToken
    text
    copied!<p>I'm developing (trying for now) portlet that will be integrated with LinkedIn.</p> <p>Following the documentation about it: <a href="http://developer.linkedin.com/docs/DOC-1008" rel="nofollow noreferrer">http://developer.linkedin.com/docs/DOC-1008</a> --> The first step to authorizing a LinkedIn member is requesting a requestToken. This request is done with an HTTP POST. For the requestToken step, the following components should be present in your string to sign:</p> <pre><code>* HTTP Method (POST) * Request URI (https://api.linkedin.com/uas/oauth/requestToken) * oauth_callback * oauth_consumer_key * oauth_nonce * oauth_signature_method * oauth_timestamp * oauth_version </code></pre> <p>I have already API(it's <em>oauth_consumer_key</em>) key and i need to generate specific URL string. Have next java code for this URL and HTTP connection:</p> <pre><code>private void processAuthentication() { Calendar cal = Calendar.getInstance(); Long ms = cal.getTimeInMillis(); Long timestamp = ms / 1000; Random r = new Random(); Long nonce = r.nextLong(); String prefixUrl = "https://api.linkedin.com/uas/oauth/requestToken"; String oauthCallback = "oauth_callback=http://localhost/"; String oauthConsumerKey = "&amp;oauth_consumer_key=my_consumer_key"; String oauthNonce = "&amp;oauth_nonce=" + nonce.toString(); String oauthSignatureMethod = "&amp;oauth_signature_method=HMAC-SHA1"; String oauthTimestamp = "&amp;oauth_timestamp=" + timestamp.toString(); String oauthVersion = "&amp;oauth_version=1.0"; String mainUrl = oauthCallback + oauthConsumerKey + oauthNonce + oauthSignatureMethod + oauthTimestamp + oauthVersion; try { prefixUrl = URLEncoder.encode(prefixUrl, "UTF-8") + "&amp;" + URLEncoder.encode(mainUrl, "UTF-8"); URL url = new URL(prefixUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); String msg = connection.getResponseMessage(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p>The question is next,for those, who had faced this problem: <strong>How should really look URL string for connection and how response is received?</strong></p> <p>For URL, it's interested the example of URL, you generated. And for response interested, method to get it. As i understand, after HTTP connection been established,that response is:</p> <pre><code>connection.getResponseMessage(); </code></pre>
 

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