The possibilty to post to friend’s walls via API will be removed in February 2013 – https://developers.facebook.com/roadmap/#february-2013:
If it fails for your app already, maybe you have the corresponding migration enabled in your settings? Anyway, not much point in developing such a thing now, since it won’t work any more in a week.
“We will remove the ability to post to a user's friends' walls via the Graph API. Specifically, posts against [user_id]/feed where [user_id] is different from the session user, or stream.publish calls where the target_id user is different from the session user, will fail.”
If you want to allow people to post to their friends' timelines, invoke the feed dialog. Stories that include friends via user mentions tagging or action tagging will show up on the friend’s timeline (assuming the friend approves the tag). For more info, see this blog post.
Edit:
@Sahil: See also this answer if it works now. I am not sure it will work now or not. But you should try once. I had made some workflow previously by selecting friend and inviting him and also posting on his wall also. I havn't tested this now, please confirm me.