我试图为我们的雇主,我有谷歌广告开发商令牌关键字搜索系统,但我无法找到任何CURL或PHP CURL安装指南。
两个参考链接Ad API Examples
Method: customers.generateKeywordIdeas
来自Google文档的示例:
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);
没有任何输出
1条答案
按热度按时间yzxexxkh1#
此示例基于Method: customers.generateKeywordIdeas
试试这个:
LINK: Handy curl conversion tool
这是我在转换工具中使用的curl代码,用于生成PHP: