how to get linkedin page views count through rest api - linkedin

In linkedin how can we get the page views count through API. There is no API for this in developer document, if any idea please share.

Try "Get statistics for a company page" using LinkedIn REST API.
https://developer.linkedin.com/docs/company-pages#statistics
"statusUpdateStatistics": {
"viewsByMonth": {
"_total": 1,
"values": [
{
"clicks": 81333,
"comments": 1203,
"date": {
"month": 1,
"year": 2015
},
"engagement": 0.003203537929382338,
"impressions": 32797489,
"likes": 20387,
"shares": 2145
}
]
}

Related

Telegram API Custom Emoji sending in message

As described in api doc for telegram - i can send custom emoji in message.
As update i receive somethings like this:
"text": "🌈",
"entities": [
{
"offset": 0,
"length": 2,
"type": "custom_emoji",
"custom_emoji_id": "5404870433939922908"
}
]
But when i'm sending same thing as message i see simple emoji:
{
"chat_id": 123,
"text": "🌈",
"entities": [
{
"offset": 0,
"length": 2,
"type": "custom_emoji",
"custom_emoji_id": "5404870433939922908"
}
]
}
Have no idea what i'm doing wrong. Help, please.
trying to send custom emoji in message through api.
AFAIK custom emoji are a premium feature and bots can't use them.

Custom image in a linked post not working through API for LinkedIn profile

linkedin
Hi,
When we replace preview of a URL with a custom image, recently we have seen that they have stopped getting posted with the custom image on LinkedIn profiles through API. It works on LinkedIn companies.
Is it a temporary bug or some change of which we were not informed?
An example given below.
Thanks.
{
"author": "urn:li:person:9DeFJQSxT0",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "hello amit recurpost.com test"
},
"shareMediaCategory": "ARTICLE",
"media": [
{
"status": "READY",
"description": {
"text": "Kickstart your social media marketing and manage multiple social accounts from a single dashboard with one powerful and affordable social media scheduling tool."
},
"originalUrl": "https://recurpost.page.link/awqx",
"thumbnails": [
{
"url": "https://rpdevelopers.blob.core.windows.net/imagesdev/1589179465_5eb8f44941d96.jpeg"
}
],
"title": {
"text": "Social Media Scheduler with Repeating Schedules | RecurPost"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}

Bad request: Attempting to associate a ugc with an asset that's not owned by the author

I'm trying to migrate my app from LinkedIn API v1 to v2. I'm currently looking at sharing images (natively) to my personal LinkedIn profile.
I'm following the official docs here: https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#create-an-image-share
To register the image I made the following POST request: to https://api.linkedin.com/v2/assets?action=registerUpload
{
"registerUploadRequest": {
"recipes": [
"urn:li:digitalmediaRecipe:feedshare-image"
],
"owner": "urn:li:person:9PyfTxBTFY",
"serviceRelationships": [
{
"relationshipType": "OWNER",
"identifier": "urn:li:userGeneratedContent"
}
]
}
}
I got the success response:
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest": {
"headers": {},
"uploadUrl": "https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1"
}
},
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw,urn:li:digitalmediaMediaArtifactClass:feedshare-uploadedImage)",
"asset": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw"
}
}
I successfully uploaded an image as binary using the returned uploadUrl:
curl -i --upload-file PATH_TO_FILE --header "Authorization: Bearer TOKEN" 'https://api.linkedin.com/mediaUpload/C4D22AQEGOHxBzKUXvw/feedshare-uploadedImage/0?ca=vector_feedshare&cn=uploads&m=AQLhYJm0KOaTCgAAAWhSDplI-Lzlfh7lOsd8D5qBcz0aJ2bf1fwIfnh8ow&app=5212106&sync=0&v=beta&ut=0rKn179ebIA8A1'
To confirm that the image is ready for use, I checked the status of the asset with the GET https://api.linkedin.com/v2/assets/C4D22AQEGOHxBzKUXvw which returned
{
"serviceRelationships": [
{
"identifier": "urn:li:userGeneratedContent",
"relationshipType": "OWNER"
}
],
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-image",
"status": "AVAILABLE"
}
],
"mediaTypeFamily": "STILLIMAGE",
"created": 1547564914979,
"lastModified": 1547564994321,
"id": "C4D22AQEGOHxBzKUXvw",
"status": "ALLOWED"
}
Based on the docs, I can now simply reference the asset URN in the UGC post.
This is the test image post I'm trying to share using the https://api.linkedin.com/v2/ugcPosts endpoint
{
"author": "urn:li:person:9PyfTxBTFY",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Testing LinkedIn image shares"
},
"shareMediaCategory": "IMAGE",
"media": [
{
"status": "READY",
"description": {
"text": "Some text"
},
"media": "urn:li:digitalmediaAsset:C4D22AQEGOHxBzKUXvw",
"title": {
"text": "Some title"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
But I keep getting the error:
{
"message": "Attempting to associate a ugc with an asset that's not owned by the author",
"status": 400
}
The above request works perfectly when trying to share a status update or a link attachment.
I haven't tried it with videos yet (similar approach) since I assume I will face the same problem. I haven't tried sharing as an organization either since I need to be accepted to the LinkedIn Marketing Developer Program first.
I can confirm that this has been fixed by the LinkedIn Developer Team. Follow the same steps as above and it should work perfectly, as long as the authenticated user has granted the w_member_social permission.
On the last request I now get 201 Created response with the header X-RestLi-Id containing the link to the new post urn:li:share:6494126499975700480.
https://www.linkedin.com/feed/update/urn:li:share:6494126499975700480
P.S. If you're re-trying an old request / registered upload, it won't work, so make sure you try it with a new asset. I believe the bug was when registering uploads.

permission error while making ugc video post on linkedin

I am trying to create video post on linkedin with new ugc endpoint
there are two steps to create this type of post
1). Upload video asset on linkedin server (done)
2). make post request to ugc endpoint with request body
I have successfully uploaded the video but getting authentication error for ugc post request. error is
{
"message": "urn:li:developerApplication:<id1> does not have permission to create ugc posts with author: li:member:<id2>",
"status": 401
}
I am passing the request body as suggested in the linkedin api docs.
{
"author": "urn:li:person:<id>",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"media": [
{
"title": {
"attributes": [],
"text": "Sample Video Create"
},
"description": {
"attributes": [],
"text": "Sample Description"
},
"media": "urn:li:digitalmediaAsset:<asset_id>",
"thumbnails": [],
"status": "READY"
}
],
"shareCommentary": {
"attributes": [],
"text": "Some share text"
},
"shareMediaCategory": "VIDEO"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
},
"targetAudience": {
"targetedEntities": [
{
"locations": [
"urn:li:country:us"
]
}
]
}
}
Please suggest how I can solve this problem. From error message it seems like I am not providing some permission. But I am not sure where I am making mistake.
This is the response I got from the LinkedIn Developer Support:
"Hi Ervin,
Creating video UGC posts is currently a whitelisted feature. There is currently hold on whitelisting new apps for video.
You may continue to create UGC posts that are not video though.
I'll put this on hold until I have more information on when we can whitelist apps again.
Best,
Alex"

How do you get data from google analytics -v4 for acquisitions - campaigns?

Can someone give an example of the query to be used?How do we access the acquisitions and then campaign data from that ?
The simplest method would be to make an Analytics Reporting API V4 request with the ga:newusers metric and the ga:source, ga:medium, ga:campaign.
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
{
"reportRequests":
[
{
"viewId": "1174",
"dateRanges":
[
{
"startDate": "2014-11-01",
"endDate": "2014-11-30"
}
],
"metrics":
[
{
"expression": "ga:newusers"
}
],
"dimensions":
[
{
"name": "ga:campaign"
},
{
"name": "ga:source"
},
{
"name": "ga:medium"
}
]
}
]
}
And again in the API Explorer.
The API also allows you to construct a cohort request to measure engagement overtime.
If you are new to Google's APIs, they make available many client libraries as well as set of quickstart guides.

Resources