I'm using wordpress to shared my post into linkedIn. For this i'm using https://api.linkedin.com/v2/ugcPosts API. But this API response return 504 gateway timeout.
In previous step when i called another API to get access token, its easily got the access token. But when I wanted to create a share using ucPosts POST api request it providing gateway time out. My requested code here.
Please any one help me.
Tried from localhost apache server(PHP, wordpress)
$params = '{
"author" : "urn:li:person:'.$linkedInAppCredentials->get_user_URN().'",
"lifecycleState" : "PUBLISHED",
"specificContent" : {
"com.linkedin.ugc.ShareContent" : {
"shareCommentary" : {
"text" : "'.$message.'"
},
"shareMediaCategory" : "NONE"
}},
"visibility" :"PUBLIC"
}';
$headers = '{
"Content-Type": "application/json",
"X-Restli-Protocol-Version": "2.0.0",
"x-li-format": "json",
"Connection": "Keep-Alive",
"Authorization": "Bearer '.$linkedInAppCredentials->getAccessToken().'"
}';
$requestedUrl = "https://api.linkedin.com/v2/ugcPosts?oauth2_access_token=".$this->getAccessToken();
$requestBody = array(
'headers' => $header,
'timeout' => 3600,
'body' => $params
);
$result = wp_remote_post($requestedUrl, $requestBody);
Response: [body] => {"message":"Request timed out","status":504} [response] => Array ( [code] => 504 [message] => Gateway Timeout )