The PHP SDK requires PHP 5.5 or greater
The PHP SDK requires composer to manage dependencies.
Add the following configuration to your composer.json
file:
{
"require": {
"weibo/ads-sdk-php": "1.0.*"
}
}
{
"respositories" : [
"type":"git",
"url" : "https://github.com/weiboad/weibo-ads-php-sdk.git"
]
}
then install it with composer:
php composer.phar install --no-dev
This SDK and its dependencies will be installed under ./vendor
.
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);
php composer.phar install --dev
./vendor/bin/phpunit
find phpunit.xml file then add annotation
<!-- <exclude>tests/IntegrationTest.php</exclude>-->
then execute phpunit command line
./vendor/bin/phpunit