我试图为我们的雇用做关键字搜索系统,我有谷歌广告开发商令牌,但我无法找到任何卷曲或PHP卷曲设置指南。
两个参考链接API示例
方法: customers.generateKeywordIdeas
谷歌文档中的一个例子:
curl -f --request POST "https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/campaignBudgets:mutate" \
--header "Content-Type: application/json" \
--header "developer-token: ${DEVELOPER_TOKEN}" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
--data "{
'operations': [
{
'create': {
'name': 'My Campaign Budget #${RANDOM}',
'amountMicros': 500000,
}
},
{
'create': {
'name': 'My Campaign Budget #${RANDOM}',
'amountMicros': 500000,
}
}
]
}"
我尝试了这段代码,但得到了错误
<?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://googleads.googleapis.com/v11/customers/(MANAGER_CUSTOMER_ID):generateKeywordIdeas');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n\n\"keywordSeed\": {\n \"keywords\": [\n \"cofee\"\n ]\n }\n}");
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Login-Customer-Id: (MANAGER_CUSTOMER_ID)';
$headers[] = 'Developer-Token: DEVELOPER_TOKEN';
$headers[] = 'Authorization: Bearer (OAUTH_ACCESS_TOKEN)';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
print_r($result);
curl_close($ch);
我没有得到任何输出
发布于 2022-10-07 04:33:49
此示例基于方法: customers.generateKeywordIdeas
尝试如下:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://googleads.googleapis.com/v11/customers/${CUSTOMER_ID}:generateKeywordIdeas');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type' => 'application/json',
'developer-token' => '${DEVELOPER_TOKEN}',
'login-customer-id' => '${MANAGER_CUSTOMER_ID}',
'Authorization' => 'Bearer ${OAUTH2_ACCESS_TOKEN}',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{ "geoTargetConstants": [ string ], "language": string, "keywordSeed": {object (KeywordSeed)},}');
$response = curl_exec($ch);
curl_close($ch);
这是我在转换工具中用来生成PHP的curl代码:
curl --request POST "https://googleads.googleapis.com/v11/customers/${CUSTOMER_ID}:generateKeywordIdeas" \
--header "Content-Type: application/json" \
--header "developer-token: ${DEVELOPER_TOKEN}" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
-d '{ "geoTargetConstants": [ string ], "language": string, "keywordSeed": {object (KeywordSeed)},}'
https://stackoverflow.com/questions/73932780
复制相似问题