参数 'targetingCriteria' 对于 LinkedIn 营销 API 的受众计数无效

Parameter 'targetingCriteria' is invalid for audience count with LinkedIn marketing API

我试图通过 Curl 和 Guzzle 请求使用 targetingCriteriaV2 来获取受众数量,但它显示为 targetingCriteria 无效。

API url 1:

https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3AcountryGroup%3Ana))),(or:(urn%3Ali%3AadTargetingFacet%3Askills:List(urn%3Ali%3Askill%3A17))))))

API url 2:

https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3AjobFunctionsList(urn%3Ali%3Afunction%3A1,urn%3Ali%3Afunction%3A8,urn%3Ali%3Afunction%3A5))))))

您应该在 API 请求中将 X-Restli-Protocol-Version: 2.0.0 作为 header 传递,例如:

curl \
   -H "Authorization:Bearer <the-token>" \
   -H "Content-Type:application/json" \
   -H "X-Restli-Protocol-Version: 2.0.0" \
   "https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3AcountryGroup%3Ana))),(or:(urn%3Ali%3AadTargetingFacet%3Askills:List(urn%3Ali%3Askill%3A17))))))"

您的 api 调用还有另外两个问题:

第一个 API 使用 legacy 地理位置:urn:li:countryGroup:na 您应该使用 BING 地理位置。作为北美的示例,您应该使用 urn:li:geo:102221843 并且 API 调用将成功,例如:

curl \
   -H "Authorization:Bearer <the token>" \
   -H "Content-Type:application/json" \
   -H "X-Restli-Protocol-Version: 2.0.0" \
   "https://api.linkedin.com/v2/audienceCountsV2?q=targetingCriteriaV2&targetingCriteria=(include:(and:List((or:(urn%3Ali%3AadTargetingFacet%3Alocations:List(urn%3Ali%3Ageo%3A102221843))),(or:(urn%3Ali%3AadTargetingFacet%3Askills:List(urn%3Ali%3Askill%3A17))))))"

{"paging":{"start":0,"count":10,"links":[]},"elements":[{"active":0,"total":2900000}]}%

第二个 API 调用似乎格式不正确,是一种非常奇怪的定位位置格式!!!!