Take the 2-minute tour ×

I'm trying to flag post-id as job discussion with OAuth PUT :

$post_id = "G-34343-example";
$cmd = "http://api.linkedin.com/v1/posts/{$post_id}/category/code";
$xml = "<?xml version='1.0' encoding='UTF-8'?><code>job</code>";
$this->oauthc->fetch($cmd, $xml, OAUTH_HTTP_METHOD_PUT, array("Content-Type" => "application/xml"));

But I'm getting an error:

Someone know what does it mean?

com.linkedin.common.leo.core.UnauthorizedActionException: Unauthorized change of forum type
share|improve this question
For your information: some people might feel some hesitation answering your question as your accept rate is 18% (out of 20 questions). It's not obligatory, but working on that could help you in the future. –  Sherlock Jan 10 '13 at 13:58
thanks for the info. –  Nimi Jan 10 '13 at 14:08
add comment

3 Answers

up vote 1 down vote accepted

Is the user you are connecting with using the API authorized to flag posts in the target group? Have you tried logging in to LinkedIn directly as this user, going to the target forum and attempted to flag a post?

share|improve this answer
Yes. The user is authorized and can flag manually as job. –  Nimi Jan 10 '13 at 15:29
And the user you've authorized granted the rw_groups permission? –  Paul Mennega Jan 10 '13 at 15:55
Do I need to use the parameter g-4793408-S-203182742 from the response header - "Location: api.linkedin.com/v1/posts/g-4793408-S-203182740"; in this way: api.linkedin.com/v1/posts/g-4793408-S-203182742/category/code in order to flag a post as job? It's what I'm trying to do and it doesn't work. –  Nimi Jan 10 '13 at 16:45
You retrieve the posts: /groups/{group-id}/posts. The API is meant to have a human perform the actions of flagging, etc, so you would pull the posts, show them to the authenticated user and they would click on 'flag' as needed. –  Paul Mennega Jan 10 '13 at 22:04
You would have to do the filtering on your side –  Paul Mennega Jan 10 '13 at 22:33
show 4 more comments

The problem lies here:

$post id = "G-34343-example";

There's a space in the variable name. Use an underscore instead of a whitespace to make it work.

(This: $cmd = "http://api.linkedin.com/v1/posts/{$post_id}/category/code"; will contain a blank spot where the post id should be.)

share|improve this answer
Oh and you should be getting PHP errors from this. Check your error reportring settings. –  Sherlock Jan 10 '13 at 14:01
Sorry, it was a typo. The error I posted is still there. –  Nimi Jan 10 '13 at 14:10
Do you have some more suggestions? –  Nimi Jan 10 '13 at 15:05
add comment

When creating a group post, it's URL is returned in the "location" header. For some reason, the URL from the location header is using http and not https.

If you're using OAuth2, LinkedIn returns a 401 if you try to access the API with http instead of htttps. So if you're getting a 401 response, check that you're using https.

So the code should be something like:

$url = $response->headers['location'] . '/category/code';
$url = str_replace('http://', 'https://', $post_url);
// ...
share|improve this answer
add comment

Your Answer


