Im目前正在开发adwords SDK。
从数据库中查询产品是否有货,并将广告设置为暂停或启用。
现在在我的while循环中,我有一个IF语句,由于某种原因,它总是正确地启动。我想也许它只使用第一个价值,而不是通过$股票循环,如果这是什么情况下的任何想法?
我需要它来运行每个库存状态。如果'有存货'后启用其他设置为暂停
继承人的代码
$sql = "SELECT * FROM MYDB.MYTBL" ;
$result = mysqli_query($conn, $sql);
if ($result) {
while($row = mysqli_fetch_array($result))
{
$adGroup = $row['adgroup'];
$adGroupId = $row['adgroup_id'];
$product = $row['product'];
$stock = $row['stock'];
$client = $row['client'];
if ($stock === "In Stock") {
if(!function_exists('UpdateAdGroupExample')){
function UpdateAdGroupExample(AdWordsUser $user, $adGroupId) {
// Get the service, which loads the required classes.
$adGroupService = $user->GetService('AdGroupService', ADWORDS_VERSION);
// Create ad group using an existing ID.
$adGroup = new AdGroup();
$adGroup->id = $adGroupId;
// Update the status.
$adGroup->status = 'ENABLED';
// Create operation.
$operation = new AdGroupOperation();
$operation->operand = $adGroup;
$operation->operator = 'SET';
$operations = array($operation);
// Make the mutate request.
$result = $adGroupService->mutate($operations);
// Display result.
$adGroup = $result->value[0];
printf("Ad group with ID '%s' has updated default bid '$%s'.\n", $adGroup->id,
$adGroup->status);
}
try {
// Get AdWordsUser from credentials in "../auth.ini"
// relative to the AdWordsUser.php file's directory.
$user = new AdWordsUser();
$user->SetClientCustomerId('XXXXXXXXX');
// Log every SOAP XML request and response.
$user->LogAll();
// Run the example.
UpdateAdGroupExample($user, $adGroupId);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}
}
try {
// Get AdWordsUser from credentials in "../auth.ini"
// relative to the AdWordsUser.php file's directory.
$user = new AdWordsUser();
$user->SetClientCustomerId('XXXXXXXXX');
// Log every SOAP XML request and response.
$user->LogAll();
// Run the example.
UpdateAdGroupExample($user, $adGroupId);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}