sodatat / oauth-as3

Automatically exported from code.google.com/p/oauth-as3
0 stars 0 forks source link

linkedIn Post doesn't work #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Not sure it's an issue or I am not using it properly. 
2. Using this code for LinkedIn , To Post in Network, need Authorization header 
with adding XML in body which should not be part of signature.

What is the expected output? What do you see instead?
how to use this library for Post. It all works fine for Twitter get/post but 
for LinkedIn Authorization header (Post/PUT) it always getting 401 
[unauthorized].. 
I fixed "," issue with oauth header but doesn't work.
What version of the product are you using? On what operating system?
Adobe AIR, For Desktop Apps, Win XP. 

Please provide any additional information below.
I think I am missing something in code, but I am not able to find any example 
how to use this for LinkedIn Updates (with Header).
Can someone please share any doc/link which explains about using header with 
this code for LinkedIn Post.
I tried LinkedIn Oauth console but doesn't seems to point the exact root cause.

Please help!!!

Original issue reported on code.google.com by sharma4r...@gmail.com on 29 Dec 2011 at 6:12

GoogleCodeExporter commented 9 years ago
Hey, 
I am also looking for the Authorization header using this library. Is there any 
docs how to use this library. 

Thanks

Original comment by komal2...@gmail.com on 29 Dec 2011 at 8:05

GoogleCodeExporter commented 9 years ago
This worked for me...

public function postNetworkUpdate(accessToken:OAuthToken, update:String):void
{
    // Construct XML request
    var xmlPost:String = "<activity locale='en_US'>" +
        "<content-type>linkedin-html</content-type>" +
        "<body>" + StringUtil.trim(update) + "</body>" +
    "</activity>"

    // Creating new oauth request to get access token
    var oauthRequest:OAuthRequest = 
        new OAuthRequest(
            OAuthRequest.HTTP_MEHTOD_POST, "http://api.linkedin.com/v1/people/~/person-activities",
            null, consumer, accessToken
        );

    // Creating new url request
    var request:URLRequest = new URLRequest(oauthRequest.requestURL);
    // Adding signed header with request parameters
    request.requestHeaders.push(oauthRequest.buildRequest(signature, OAuthRequest.RESULT_TYPE_HEADER));
    // The request method is POST
    request.method = URLRequestMethod.POST;
    // The request content type
    request.contentType = "application/xml";
    // Passing xml as POST data
    request.data = xmlPost;

    // Invoking remote service with URLLoader
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, postNetworkUpdate_completeHandler);
    loader.addEventListener(IOErrorEvent.IO_ERROR, postNetworkUpdate_ioErrorHandler);
    loader.load(request);
}

Hope it helps

Original comment by ticap...@gmail.com on 29 Jan 2012 at 9:31

GoogleCodeExporter commented 9 years ago
Yes, It worked. Thanks.

Original comment by sharma4r...@gmail.com on 30 Jan 2012 at 9:09