ebx / ebx-linkedin-sdk Goto Github PK
View Code? Open in Web Editor NEWA pure Java LinkedIn API client which implements the v2 API.
License: Apache License 2.0
A pure Java LinkedIn API client which implements the v2 API.
License: Apache License 2.0
In class com.echobox.api.linkedin.types.posts.ReshareContext all Fields are private.
But here for reshare-creation-request reshareContext.parent field must be provided.
As all fields are private cant't set reshareContext.parent field
N.B: using sdk version 4.1.0 with linkedin versioned client.
It is currently impossible to deserialize PollOption
and PollSettings
object.
class com.echobox.api.linkedin.exception.LinkedInJsonMappingException: Don't know
how to map JSON to class com.echobox.api.linkedin.types.posts.PollOption. Are you sure you're mapping to the right class?
Offending JSON is '{"isVotedByViewer":false,"voteCount":0,"text":"test option"}'.
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toPrimitiveJavaType(DefaultJsonMapper.java:643)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:256)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaList(DefaultJsonMapper.java:190)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:730)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:320)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:747)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:320)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:747)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:320)
com.echobox.api.linkedin.client.Connection.<init>(Connection.java:173)
com.echobox.api.linkedin.client.DefaultVersionedLinkedInClient.fetchConnection(DefaultVersionedLinkedInClient.java:356)
com.echobox.api.linkedin.connection.versioned.VersionedPostConnection.retrievePostsByAuthor(VersionedPostConnection.java:100)
When I am trying to create a new campaign using create campaign API, sending the runschedule as long format "runSchedule": { "end": 1624329157, "start": 1622601157 }
but defaultclient is throwing an error like this for date and boolean data type
`{"errorDetailType":"com.linkedin.common.error.BadRequest","message":"Multiple errors occurred during the input validation. Please see errorDetails for more information.","errorDetails":{"inputErrors":[{"description":"ERROR :: /runSchedule/start :: {} cannot be coerced to Long","input":{"inputPath":{"fieldPath":"/Campaign/runSchedule/start"}},"code":"INVALID_VALUE"},{"description":"Invalid value for field; wrong type or otherwise invalid input","input":{"inputPath":{"fieldPath":"/runSchedule/start"}},"code":"INVALID_VALUE"}]},"status":400}`
may I know what is the issue, why this is happening and If you could give me the documentation impl examples for each method call GET, POST, PUT that would be great.
Hi,
for some reason I wanted to deserialize a json string to the com.echobox.api.linkedin.types.posts.Post
class with Gson and I got the following error message:
java.lang.IllegalArgumentException: class com.echobox.api.linkedin.types.posts.Post declares multiple JSON fields named id
Turns out, the field private URN id;
is definied both in the Post
class and in it's base class LinkedInURNIdType
. Does this have a reason or would it be sufficient to just have the field in the latter class? As far as I understand that is what base classes are for, to just have it in one place.
Definition in the Post
class:
/**
* ugcPostUrn or shareUrn
*/
@Getter
@Setter
@LinkedIn
private URN id;
Definition in the LinkedInURNIdType
class:
/**
* Unique id for this object. Can contain more urn types in the future.
*/
@Getter
@LinkedIn("id")
private URN id;
Best regards,
xberger
Hi, I'm converting a Post class jsonString to its object.
String expectedPostJson = "{\"author\":\"urn:li:organization:social_network_id\",\"commentary\":\"sample post text\",\"content\":{\"multiImage\":{\"images\":[{\"id\":\"urn:li:image:imageId1\"},{\"id\":\"urn:li:image:imageId2\"}]}},\"distribution\":{\"feedDistribution\":\"MAIN_FEED\"},\"lifecycleState\":\"PUBLISHED\",\"visibility\":\"PUBLIC\"}";
JsonMapper jsonMapper = new DefaultJsonMapper();
Post p = jsonMapper.toJavaObject(expectedPostJson, Post.class);
But I'm getting exception
com.echobox.api.linkedin.exception.LinkedInJsonMappingException: Unable to create an instance of class com.echobox.api.linkedin.types.posts.MultiImageContent. Please make sure that if it's a nested class, is marked 'static'. It should have a no-argument constructor.
at com.echobox.api.linkedin.util.ReflectionUtils.createInstance(ReflectionUtils.java:411)
at com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:279)
at com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:747)
at com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:320)
at com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:747)
at com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:320)
at com.bcv.pipeline.process.linkedin.content.LinkedInContentProcessTest.testSuccess(LinkedInContentProcessTest.java:29)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.NoSuchMethodException: com.echobox.api.linkedin.types.posts.MultiImageContent.<init>()
at java.base/java.lang.Class.getConstructor0(Class.java:3585)
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754)
at com.echobox.api.linkedin.util.ReflectionUtils.createInstance(ReflectionUtils.java:400)
... 33 more
Can somebody please help me resolving this issue. ๐
When I want to uploas a asset I have problems when add the fields: fileSize and supportedUploadMechanism
The code to build the RegisterUploadRequestBody
is:
val owner = URN("$URN_PERSON:$personId")
val recipe = listOf(when (category) {
MediaCategory.IMAGE -> RegisterUploadRequestBody.RecipeURN.FEED_SHARE_IMAGE
MediaCategory.VIDEO -> RegisterUploadRequestBody.RecipeURN.FEED_SHARE_VIDEO
})
val fileSizeMb = fileSize / (1024.0 * 1024.0)
val supportedUploadMechanism = if (fileSizeMb > 200.0) {
throw ValidationException("Not supported upload file with $fileSizeMb MB size")
} else {
RegisterUploadRequestBody.SupportedUploadMechanism.SINGLE_REQUEST_UPLOAD
}
val registerUploadRequest = RegisterUploadRequestBody.RegisterUploadRequest(owner)
registerUploadRequest.setRecipes(recipe)
registerUploadRequest.fileSize = fileSize
registerUploadRequest.supportedUploadMechanism = supportedUploadMechanism
registerUploadRequest.serviceRelationships = listOf(RegisterUploadRequestBody.ServiceRelationships(SERVICE_RELATIONSHIP_IDENTIFIER, RelationshipType.OWNER))
return RegisterUploadRequestBody(registerUploadRequest)
And I do:
val assetsConnetion = AssetsConnection(client)
val assetURN = assetsConnetion.uploadImageAsset(registerUploadRequestBody, <fileName>, <File>)
Then, the response is:
Received LinkedIn error response:
Parameters of method 'registerUpload' failed validation with error
'
ERROR :: /registerUploadRequest/supportedUploadMechanism :: array type is not backed by a DataList
ERROR :: /registerUploadRequest/fileSize :: {} cannot be coerced to Long
' (code null)
I need to support upload files longer than 200MB, so I need to use RegisterUploadRequestBody.SupportedUploadMechanism.MULTIPART_UPLOAD
and I can't do that now
This is needed for processing boolean fields within the request bodies of certain calls like the videos initializeUpload call.
The method needs a clause similar to:
} else if (jsonValue.isBoolean()) {
value = jsonValue.asBoolean();
}
Hi,
I need to do a request to the me endpoint but I can't find how do that with the library.
Dose anyone have an idea of how to do it?
I'm trying to upload an asset and I received the following error
com.echobox.api.linkedin.exception.LinkedInQueryParseException: Received LinkedIn error response: Parameters of method 'registerUpload' failed validation with error 'ERROR :: /registerUploadRequest/supportedUploadMechanism :: array type is not backed by a DataList
Dec 28 16:30:32 int-com-wutsi-blog app/web.1 ' (code null)
Dec 28 16:30:32 int-com-wutsi-blog app/web.1 at com.echobox.api.linkedin.client.DefaultLinkedInClient$DefaultLinkedInExceptionMapper.exceptionForTypeAndMessage(DefaultLinkedInClient.java:720)
Dec 28 16:30:32 int-com-wutsi-blog app/web.1 at com.echobox.api.linkedin.client.DefaultLinkedInClient.throwLinkedInResponseStatusExceptionIfNecessary(DefaultLinkedInClient.java:698)
Dec 28 16:30:32 int-com-wutsi-blog app/web.1 at com.echobox.api.linkedin.client.DefaultLinkedInClient.makeRequestAndProcessResponse(DefaultLinkedInClient.java:638)
....
Looking at linked in specs here
supportedUploadMechanism
should be a listRegisterUploadRequestBody.supportedUploadMechanism
is not in the code.Is this the issue?
I can load the video with RegisterUploadRequestBody.RecipeURN.FEED_SHARE_VIDEO
in the endpoint assetsConnection.uploadImageAsset
.
But then when I try to post, in the UGCShare
putting in the ShareContentBody()
the attribute contentBody.shareMediaCategory = LinkedInConstants.SHARE_MEDIA_CATEGORY_VIDEO
the service response is Received LinkedIn error response: LinkedIn request failed (code null)
For now I'm using SHARE_MEDIA_CATEGORY_IMAGE instead SHARE_MEDIA_CATEGORY_VIDEO to post a image of the video instead of the video. But I need to post the Video as a Video.
When migrating to the new Versioned LinkedIn API, it appears that they no longer crawl the URL given with the post for metatags as they did in v2.
From my research, it looks like you now need to use the new Image API to upload an image to LinkedIn first and then pass the returned image URN with the createPost request.
I've looked around for an example of how to upload an image, but couldn't find any information on how to do this with the SDK.
Would it be possible to point me to an example of how to do this, or perhaps update the README to include additional examples for working with images?
Thank you.
How to share to linkedin a link with a different thumbnail, considering that the class Thumbnail is readonly?
Thanks
Hello and thanks for your great library!
I have a general question:
At the home page of my personal LinkedIn account https://www.linkedin.com/feed/ I can see the feed with all posts of all connected users.
Is it possible to access such posts via LinkedIn API and your library ? if so, could you please point me to appropriate API documentation or example? Thanks!
PR raised:
#144
Unlike the VersionedImageConnection
class, VersionedVideoConnection
doesn't provide support for fetching video details.
It is currently impossible to get the digitalmediaAsset
from a comment object that has the content
field valorized (for example, a comment with an attached picture), because it is not mapped in the CommentAction
class.
Here is an example json with the valorized field:
{
"paging": { "start": 0, "count": 10, "links": [], "total": 1 },
"elements": [
{
"actor": "urn:li:organizationBrand:xxx",
"created": {
"actor": "urn:li:organizationBrand:xxx",
"impersonator": "urn:li:person:xxx",
"time": 1676467685592
},
"lastModified": {
"actor": "urn:li:organizationBrand:xxx",
"impersonator": "urn:li:person:xxx",
"time": 1676467685592
},
"id": "xxx",
"$URN": "urn:li:comment:(urn:li:activity:xxx,xxx)",
"message": { "attributes": [], "text": "test comment" },
"content": [
{
"type": "IMAGE",
"entity": {
"digitalmediaAsset": "urn:li:digitalmediaAsset:xxx"
},
"url": "https://media.licdn.com/dms/image/xxx"
}
],
"object": "urn:li:activity:xxx"
}
]
}
Hi, can you give me an example for sharing an Image with a post? I can upload a text post with the example from the README but I failed at adding an image to the shareContent object.
Unable to collect Statistics for UGC post since the URNEntityType is expected to be of Type SHARE whereas I'm trying to collect the stats for an UGC post. Is there a method to find the Stats for an UGC Post or should ebx-linkedin-sdk be updated for this?
The URN should be type SHARE at com.echobox.api.linkedin.connection.ConnectionBase.validateURN(ConnectionBase.java:86) at com.echobox.api.linkedin.connection.v2.ConnectionBaseV2.validateShareURN(ConnectionBaseV2.java:103)
Code used:
DefaultLinkedInClient client = new DefaultLinkedInClient(Version.DEFAULT_VERSION);
LinkedInClient.AccessToken accessToken = client.obtainUserAccessToken("client_id", "client_secret",
"redirect url", code);
The below is the error at Line 343(String response) DefaultLinkedInClient.class
ERROR:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Header</h2>
<hr><p>HTTP Error 400. The request has an invalid header name.</p>
</BODY></HTML>
Version:
com.echobox
ebx-linkedin-sdk
2.0.0
It is currently impossible to deserialize the ReshareContext
class
class com.echobox.api.linkedin.exception.LinkedInJsonMappingException: Don't know
how to map JSON to class com.echobox.api.linkedin.types.posts.ReshareContext. Are you sure you're mapping to the right class?
Offending JSON is '{"parent":"urn:li:share:xxx","root":"urn:li:share:xxx"}'.
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toPrimitiveJavaType(DefaultJsonMapper.java:643)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:256)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaType(DefaultJsonMapper.java:747)
com.echobox.api.linkedin.jsonmapper.DefaultJsonMapper.toJavaObject(DefaultJsonMapper.java:320)
com.echobox.api.linkedin.client.Connection.<init>(Connection.java:173)
com.echobox.api.linkedin.client.DefaultVersionedLinkedInClient.fetchConnection(DefaultVersionedLinkedInClient.java:356)
com.echobox.api.linkedin.connection.versioned.VersionedPostConnection.retrievePostsByAuthor(VersionedPostConnection.java:100)
The DefaultLinkedInExceptionMapper inner class within DefaultVersionedLinkedInClient.java and DefaultLinkedInClient.java should have a public constructor. Without it, subclasses of those client classes that want to call super constructors that take a LinkedInExceptionMapper parameter can't instantiate DefaultLinkedInExceptionMapper if they want to use that.
In particular, the only DefaultVersionedLinkedInClient constructor that allows the versionedMonth to be overridden can't currently be called without also specifying a non-default LinkedInExceptionMapper.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.