I want to get my metric share statistics from my page LinkedIn, the docs in here: https://learn.microsoft.com/en-us/linkedin/marketing/community-management/organizations/share-statistics?view=li-lms-2024-06&tabs=curl
I tried in postman is working well, but when i implement to my code (i’m using PHP) is getting error:
{ “errorDetailType”: “com.linkedin.common.error.BadRequest”, “message”: “Invalid param. Please see errorDetails for more information.”, “errorDetails”: { “inputErrors”: [ { “description”: “Invalid value for param; wrong type or other syntax error”, “input”: { “inputPath”: { “fieldPath”: “timeIntervals” } }, “code”: “PARAM_INVALID” } ] }, “status”: 400 }
Here is my code:
$date_start = strtotime(date('Y-01-01 00:01:01'));
$date_end = strtotime(date('Y-m-d H:i:s'));
$response = Http::withHeaders([
'Authorization' => 'Bearer ' . $accessToken,
'Linkedin-Version' => '202406',
'X-Restli-Protocol-Version' => '2.0.0',
])->get('https://api.linkedin.com/rest/organizationalEntityShareStatistics', [
'q' => 'organizationalEntity',
'organizationalEntity' => 'urn:li:organization:XXXXXXXX',
'timeIntervals' => '(timeGranularityType:DAY,timeRange:(start:'.$date_start.',end:'.$date_end.'))',
]);
return $response->json();
When i do $date_start
& $date_end
in hardcode like:
$date_start = 1704067200000;
$date_end = 1717113600000;
the result is still same error
But, when im not using timeIntervals
params, is working well
What’s wrong with my code?
Thank you so much for you who answered and help me.
Ontagen Onta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3