Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when performing TargetingSearch as per the example #39

Closed
cornernote opened this issue Nov 25, 2014 · 2 comments
Closed

error when performing TargetingSearch as per the example #39

cornernote opened this issue Nov 25, 2014 · 2 comments

Comments

@cornernote
Copy link

Here is my code:

\FacebookAds\Api::init($app_id, $app_secret, $access_token);
$results = \FacebookAds\Object\TargetingSearch::search(
    $type = \FacebookAds\Object\Search\TargetingSearchTypes::INTEREST,
    $class = null,
    $query = 'facebook'
);
print_r($results);

The error is:
Argument 1 passed to FacebookAds\Cursor::__construct() must implement interface FacebookAds\Http\ResponseInterface, array given, called in /vagrant/app/vendor/facebook/php-ads-sdk/src/FacebookAds/Object/TargetingSearch.php on line 74 and defined in file /vagrant/app/vendor/facebook/php-ads-sdk/src/FacebookAds/Cursor.php at line 84

@paulbain
Copy link
Contributor

did you update to the latest version of the repo? this was fixed in 2.2:
329dcc0

also it's probably better to import the files you want from the namespaces rather than fully qualifying every class:

use FacebookAds\Api;
use \FacebookAds\Object\TargetingSearch;
use \FacebookAds\Object\Search\TargetingSearchTypes;

Api::init($app_id, $app_secret, $access_token);

$results = TargetingSearch::search(
    TargetingSearchTypes::INTEREST,
    null,
    'facebook'
);
print_r($results);

@cornernote
Copy link
Author

Updated to latest, works now.

I hate that I can't use namespace imports inside a class/method, so I do them inline. It's probably more readable to put them at the top of the class file so I might start doing that.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants