1

i am trying to make the post using my linkedin api application, The issue with my app is i am not able to make any post on the group wall...even i am able to make a comment on any post of group but not able to make any new post.

I have given access to third party to make a post but some how i am not able to make a new post on group wall.....

Following is the my code to make a post on group's wals.....it gets executed without any error...can anybody help me out with this?

    function setGroupPost($status) {           
    $status_url = $this->base_url . "v1/groups/676767/posts";  
    $xml = "<post><title>" . htmlspecialchars($status['title'], ENT_NOQUOTES, "UTF-8") . "</title><summary>".htmlspecialchars($status['description'], ENT_NOQUOTES, "UTF-8")."</summary></post>";      
    $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $status_url);

    $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
    $auth_header = $request->to_header("https://api.linkedin.com");
    /*if ($debug) {
      echo $auth_header . "\n";
    } */
    $response = $this->httpRequest($status_url, $auth_header, "POST", $xml);
    return $response;
  }
Jimit Shah
  • 92
  • 1
  • 10

2 Answers2

1

I'm curious what the status is on the server response. In any case I'm able to make a post to a group using my python code - here's the trace on the HTTP traffic:

URL:
http://api.linkedin.com/v1/groups/4058745/posts

Request Headers:
user-agent: Python-httplib2/0.7.0 (gzip)
Host: api.linkedin.com
accept-encoding: gzip, deflate
content-type: text/xml
Content-Length: 64
authorization: OAuth realm="http://api.linkedin.com",  oauth_body_hash="FWbw5dO9thxZvF2L2gMq8d6CTwM%3D", oauth_nonce="14208603", oauth_timestamp="1326913388", oauth_consumer_key="1iK9RUZ1FLJaLUpp90xztjhJXLkdTooiNqXMAORUrpoWJaR0cozd863qyIwvb0ZJ", oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oauth_token="3df261cb-0532-4015-8618-01b0a41cd45e", oauth_signature="Rwv%2BNdFpJuBzoXWSmyYwIT%2FiiC8%3D"

Request body:
<post><title>Test group post</title><summary> </summary></post>

Thoughts: perhaps your Content-Type is not set correctly (must be text/xml)? Can you check the status on the HTTP Response? Generally if it's not a "201 created" then there was an issue, and the code itself can give you guidance about where it's going awry.

Kirsten Jones
  • 2,681
  • 1
  • 17
  • 20
  • 200 OK sounds like you're actually sending a GET and not a POST. Can you watch the HTTP traffic? If you're using a macintosh you can use HTTPScoop to do this (you'll need to switch from https to http). If you're using a PC you can use Fiddler. A successful write to the LinkedIn API will return a 201, not a 200. – Kirsten Jones Jan 19 '12 at 18:25
  • OAuthrealm="linkedin.com";, oauth_version="1.0", oauth_nonce="cfaa01a68bb6affa2c463aff3e6dbbcf", oauth_timestamp="1328013867", oauth_consumer_key="qqiqyu34efp", oauth_signature_method="HMAC-SHA1", oauth_signature="Kw0yIMf7lULGQKw6PAsOgQfR5nM%3D" getting above details in my http header – Jimit Shah Jan 31 '12 at 13:02
  • If you're sniffing the http traffic as I suggested, you need to check the whole request body and all headers as well as the response. And a 200 really sounds like you're sending a get, not a post. – Kirsten Jones Jan 31 '12 at 14:23
0

Try replacing :


$auth_header = $request->to_header("https://api.linkedin.com");
// WITH
$auth_header = $request->to_header("https://www.linkedin.com");

Hope it works for you

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162