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

Updating Campaign #23

Closed
NAVNEETOJHA opened this issue Sep 26, 2016 · 6 comments
Closed

Updating Campaign #23

NAVNEETOJHA opened this issue Sep 26, 2016 · 6 comments

Comments

@NAVNEETOJHA
Copy link

I want to update campaign using this sdk, but I am not able to do so. If you are having an example for that , it would be great. I am able to create campaign but not update.

@hborras
Copy link
Owner

hborras commented Sep 26, 2016

Hi!

What have you tryed so far?

Once you have the campaign as -> $campaign.

You should change whatever you want with the setters:

$campaign->setName("New campaign name");

And, later call the save method

$campaign->save();

Have you tried this?

Thanks

@NAVNEETOJHA
Copy link
Author

I have tried this, main problem is that, I don't know how to pass the campaign id. I don't know the first step having campaign as -> $campaign.

@hborras
Copy link
Owner

hborras commented Sep 26, 2016

Oh! Okey!

You have two possibilities, if you create a new campaign with the sdk is easy, because when you create it you have the variable.

If you want to retrieve the campaign using the id you should use:

$campaign = new Campaign($account);
$campaign->load($id);

This should work :)

@NAVNEETOJHA
Copy link
Author

NAVNEETOJHA commented Sep 26, 2016

Thank you so much for your instant help 😄
May be I am doing something wrong.
It is giving me this error

PHP Fatal error: Uncaught exception 'Hborras\TwitterAdsSDK\TwitterAds\Errors\NotFound' with message 'NOT_FOUND' in /var/www/html/twitter-php-ads-sdk-master/src/TwitterAds.php:432
Stack trace:
#0 /var/www/html/twitter-php-ads-sdk-master/src/TwitterAds.php(408): Hborras\TwitterAdsSDK\TwitterAds->manageErrors(Object(stdClass))
#1 /var/www/html/twitter-php-ads-sdk-master/src/TwitterAds.php(221): Hborras\TwitterAdsSDK\TwitterAds->http('GET', 'https://ads-api...', 'accounts/18ce54...', Array)
#2 /var/www/html/twitter-php-ads-sdk-master/src/TwitterAds/Resource.php(69): Hborras\TwitterAdsSDK\TwitterAds->get('accounts/18ce54...', Array)
#3 /var/www/html/twitter-php-ads-sdk-master/examples/quick_start.php(25): Hborras\TwitterAdsSDK\TwitterAds\Resource->load('10119006')
#4 {main}
thrown in /var/www/html/twitter-php-ads-sdk-master/src/TwitterAds.php on line 432

@hborras
Copy link
Owner

hborras commented Sep 26, 2016

It looks like the resource you're tryning to get doesn't exist.

Looking into the Stack Trace, I see that here:

/var/www/html/twitter-php-ads-sdk-master/examples/quick_start.php(25): Hborras\TwitterAdsSDK\TwitterAds\Resource->load('10119006')

You'retring to load id '10119006', but you can't use numbers in base 10 in the API, you should transform it before to base 36. Is the way Twitter works.

http://www.unitconversion.org/numbers/base-10-to-base-36-conversion.html

@NAVNEETOJHA
Copy link
Author

Thank you 👍
It worked 😄 .

@hborras hborras closed this as completed Sep 26, 2016
@ghost ghost mentioned this issue Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants