Facebook Ad API创建广告系列问题

时间:2015-03-16 18:34:05

标签: php api facebook-graph-api

我试图通过php-and-sdk

将广告系列添加到FB

我的代码是:

$ACCOUNT_ID = '653669201111111';
$APP_ID = '671119719111111';
$APP_SECRET = 'fb9da35ce4709866817f5f7b85111111';
$CLIENT_TOKEN = '05483f8023bd5885bef5e2f08611111';
$APP_TOKEN = '6012878111111';

FacebookSession::setDefaultApplication($APP_ID, $APP_SECRET);

// If you already have a valid access token:
$session = new FacebookSession('05483f8023bd5885bef5e2f086111111');

$session = FacebookSession::newAppSession($APP_ID,$APP_SECRET);

// To validate the session:
try {
    $session->validate();
} catch (Facebook\FacebookRequestException $ex) {
    echo $ex->getMessage();
} catch (\Exception $ex) {
    echo $ex->getMessage();
}

$__TOKEN__ = $session->getToken();

$session = new \FacebookAds\Session($APP_ID,$APP_SECRET,$session->getToken());

Api::init($APP_ID, $APP_SECRET, $__TOKEN__);

$api = Api::instance();

$campaign = new \FacebookAds\Object\AdCampaign(null,"act_$ACCOUNT_ID");
$campaign->setData(array(
    AdCampaignFields::NAME => 'My First Campaign',
    AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CLICKS,
    AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED,
));

$campaign->create();
echo "Campaign ID:" . $campaign->id . "\n";
die;

得到这样的回应:

我试图追踪这个问题,但对我来说仍然没用。

FacebookAds\Http\Response Object
(
[request:protected] => 
[statusCode:protected] => 400
[headers:protected] => FacebookAds\Http\Headers Object
    (
        [storage:ArrayObject:private] => Array
            (
                [http_code] => HTTP/1.1 400 Bad Request
                [Content-Type] => application/json; charset=UTF-8
                [WWW-Authenticate] => OAuth "Facebook Platform" "invalid_request" "Unsupported post request."
                [Access-Control-Allow-Origin] => *
                [X-FB-Rev] => 1643773
                [Pragma] => no-cache
                [Cache-Control] => no-store
                [Facebook-API-Version] => v2.2
                [Expires] => Sat, 01 Jan 2000 00:00:00 GMT
                [Vary] => Accept-Encoding
                [X-FB-Debug] => hQE7mRn8ZYmolpN+FckJjwPW2c0iFwZeoPnegV2oavAvzXURrR5MZxiCLRAGOIr7Q1zaWpM9hEajZxlHiZxirg==
                [Date] => Mon, 16 Mar 2015 18:05:22 GMT
                [Connection] => keep-alive
                [Content-Length] => 90
            )

    )

[body:protected] => {"error":{"message":"Unsupported post request.","type":"GraphMethodException","code":100}}
[content:protected] => 

我正在使用PHP 5.4

有什么想法吗?

谢谢!

0 个答案:

没有答案