PHP code example of weibo / ads-sdk-php

1. Go to this page and download the library: Download weibo/ads-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

weibo / ads-sdk-php example snippets


use WeiboAd\Api;

$api = new Api('your_app_id', 'your_app_secret', 'your_access_token');

use WeiboAd\Core\AccountApi;  

$accountApi = new AccountApi($this->api);
$account = $accountApi->read();

use WeiboAd\Core\CampaignApi;  
use WeiboAd\Core\Entity\Campaign;
use WeiboAd\Core\Constant\ConfiguredStatus;
use WeiboAd\Core\Constant\MarketingObjective;

//create campaign
$campaignApi = new CampaignApi($this->api);
$campaign = new Campaign();
$campaign->setName('campaign name');
$campaign->setConfiguredStatus(ConfiguredStatus::PAUSE);
$campaign->setObjective(MarketingObjective::BRAND_AWARENESS);
$campaign->setLifetimeBudget(600);
$campaign->setGuaranteedDelivery(false);
$retCampaign = $campaignApi->create($campaign);

//update campaign budget
$campaign = $campaignApi->read($id);
$campaign->setLifetimeBudget(1000);
$retCampaign = $campaignApi->update($campaign);
json
{
    "eibo/ads-sdk-php": "1.0.*"
    }
}  
shell
php composer.phar install --no-dev
shell
php composer.phar install --dev