Google Dfp Api Step by Step

1,125 views
Skip to first unread message

geob...@gmail.com

unread,
Jan 25, 2017, 2:10:22 PM1/25/17
to Google's DoubleClick for Publishers API Forum
Hi, after many times of trying I'm still not able to get the result.
Could you please tell me which step is incorrect.

1) I'm downloading client API files, putting them on my server's public_html folder
2) Then using composer installing dependencies from composer.json.(adding vendor folder)
3) Copied adsapi_php.ini to the public_html
4) Inside adsapi_php.ini inserted network code, application name, clientId, clientSecret, refreshtoken (that I got from ouath playground), server's settings in a Proxy block, log files links in the same directory and log level - notice.
5) Copied GetAllLineItems.php from examples to public_html.
6) Changed these lines of code inside GetAllLineItems.php.

namespace Google\AdsApi\Examples\Dfp\v201611\LineItemService;
require '../../../../vendor/autoload.php';

with

namespace Google\AdsApi;
require 'vendor/autoload.php';

7) Running GetAllLineItems.php in console line.

Then I get this error.


My network code is 22133002, Log files don't update, firewall does not block anything, I have tried on other servers as well, but results are the same. I don't have SSL certificate on my domain.
I think there is obviously something that I don't know or miss.

Thanks in advance.

Tesfamichael Hailegeorgis(DFP API Team)

unread,
Jan 25, 2017, 5:14:56 PM1/25/17
to Google's DoubleClick for Publishers API Forum
Hi,

To clarify, are you setting up the PHP library for the first time or is this happening while you try to upgrade to the latest version, v201611? In either case, please double-check if you have followed the instructions as specified in the upgrading guide. For more on the new PHP ads client library, check this blog post.

Feel free to let us know how this goes.

Thanks,
Tesfamichael Hailegeorgis, DFP API Team

geob...@gmail.com

unread,
Jan 25, 2017, 5:34:21 PM1/25/17
to Google's DoubleClick for Publishers API Forum
Hi, yes, this is the first time I used Google's php library. I followed installation instructions, but I get this error.

Chris Seeley

unread,
Jan 26, 2017, 11:36:51 PM1/26/17
to Google's DoubleClick for Publishers API Forum
Can you clarify what you mean by "I don't have SSL certificate on my domain"? Are the other servers you tried on on the same network? I tried to reproduce this using your steps but the example ran as expected.

Have you tried just making a curl request in your php script to the WSDL URL?

Thanks,
Chris Seeley, DFP API Team

geob...@gmail.com

unread,
Jan 28, 2017, 7:47:23 PM1/28/17
to Google's DoubleClick for Publishers API Forum
Hi Chris, 
Thanks for the reply. Regarding SSL certificate I meant I don't have the https address(not sure if it's necessary), only Http. 
Yes, I also tried another network. 
I attached PHP info file of my server, as you can see, Soap, OpenSSL, and Curl extensions are enabled. 

Using this code:
$wsdl = file_get_contents('');
echo $wsdl;

I tried to make the curl request to the WSDL URL in PHP and it works so there is no connectivity problem.

I also tried to change the default socket timeout to 180. But unfortunately, I get the same error.

Thanks.
phpinfo.pdf

Vincent Tsao

unread,
Jan 30, 2017, 2:38:06 PM1/30/17
to Google's DoubleClick for Publishers API Forum
Hello:

Can you please post your adsapi_php.ini file with your OAuth2 credentials removed so that I can see your exact settings. It sounds like you're using a proxy is that correct? Is it possible to try making an API call without a proxy to see if your proxy is causing an issue?

Thanks,
Vincent Tsao, DFP API Team
Message has been deleted

geob...@gmail.com

unread,
Jan 30, 2017, 4:20:57 PM1/30/17
to Google's DoubleClick for Publishers API Forum
Hi Vincent,
Yes I tried to run it without proxy settings as well, but it was showing this error: 

Uncaught SoapFault exception: [HTTP] Unauthorized in /home/jon i/web/glob.space/public_html/src/Google/AdsApi/Common/AdsSoapClient.php

After that, I tried to use proxy settings:
host: my server IP
port: 21
user: FTP user(at the same time server username)
password: the same password for both server and FTP users.

Thanks for attention.
adsapi_php.ini

Vincent Tsao

unread,
Jan 31, 2017, 11:35:58 AM1/31/17
to Google's DoubleClick for Publishers API Forum
Okay, so let's try to get this working without setting a proxy first. Can you send me the SOAP logs when you try to make a call with no proxy settings set? And are you running this from a server? Can you try running it from a local machine as well?

Thanks,
Vincent Tsao, DFP API Team


geob...@gmail.com

unread,
Jan 31, 2017, 2:08:42 PM1/31/17
to Google's DoubleClick for Publishers API Forum
Hi Vincent, 

1) I attached the soap.log file which I get after running the code without proxy settings from a server. And shows this error:  server.png

2) As you suggested I also tried to run the code locally, but in this case, I get another error: local.png

Thank you.
soap.log
server.PNG
local.PNG

Vincent Tsao

unread,
Jan 31, 2017, 2:32:25 PM1/31/17
to Google's DoubleClick for Publishers API Forum
Alright let's focus on getting this example to work on your local machine. So you have an SSL error, it states that Curl cannot find SSL certs on your system, which are needed to make proper SSL calls. Fixing this issue usually depends on your setup/framework you're using - I would Google for that error for help on how to ensure Curl is able to locate your SSL certs on your local system.

Once that's done, run the example again on your local machine to see if it works, if not, send me the SOAP logs for your local machine.

Thanks,
Vincent Tsao, DFP API Team

geob...@gmail.com

unread,
Jan 31, 2017, 3:15:44 PM1/31/17
to Google's DoubleClick for Publishers API Forum
Ok, I found a solution to the SSL certificate's issue on the local system. I followed these steps http://stackoverflow.com/questions/29822686/curl-error-60-ssl-certificate-unable-to-get-local-issuer-certificate/34883260#34883260 and got to the same point as with remote server. I get the exactly same error: 

Fatal error: Uncaught SoapFault exception: [HTTP] Unauthorized in C:\xampp1\htdocs\pub\src\Google\AdsApi\Common\AdsSoapClient.php:75
Stack trace:
#0 C:\xampp1\htdocs\pub\src\Google\AdsApi\Common\AdsSoapClient.php(75): SoapClient->__doRequest('<?xml version="...', 'https://ads.goo...', '', 1, 0)
#1 [internal function]: Google\AdsApi\Common\AdsSoapClient->__doRequest('<?xml version="...', 'https://ads.goo...', '', 1, 0)
#2 C:\xampp1\htdocs\pub\src\Google\AdsApi\Common\AdsSoapClient.php(116): SoapClient->__soapCall('getLineItemsByS...', Array, NULL, Array, Array)
#3 C:\xampp1\htdocs\pub\src\Google\AdsApi\Dfp\v201611\LineItemService.php(220): Google\AdsApi\Common\AdsSoapClient->__soapCall('getLineItemsByS...', Array)
#4 C:\xampp1\htdocs\pub\lineitems.php(53): Google\AdsApi\Dfp\v201611\LineItemService->getLineItemsByStatement(Object(Google\AdsApi\Dfp\v201611\Statement))
#5 C:\xampp1\htdocs\pub\lineitems.php(88): Google\AdsApi\GetAllLineItems::runExample(Object(Google\AdsApi\Dfp\DfpServices), Object(Google\AdsApi\Dfp\DfpSession in C:\xampp1\htdocs\pub\src\Google\AdsApi\Common\AdsSoapClient.php on line 75

However, the local soap.log file is empty.

Thank you.

Vincent Tsao

unread,
Feb 1, 2017, 12:39:44 PM2/1/17
to Google's DoubleClick for Publishers API Forum
What is your network configuration like for your local machine? Are you behind any kind of firewall that might be blocking a call to the WSDL?

Also, are you running the GetAllLineItems example from a command line? Our examples are meant to be run from the command line and not a webpage.

Also I don't see a vendor folder in the path to AdsSoapClient - can you confirm you installed this via Composer?

This might be a configuration issue with XAMPP - do you need to whitelist which URLs you can access in some XAMPP config? To rule this out, can you install the library via Composer locally without using XAMPP and run one of the examples via the command line to see if that works?

Thanks,
Vincent Tsao, DFP API Team

Message has been deleted

geob...@gmail.com

unread,
Feb 2, 2017, 6:36:51 PM2/2/17
to Google's DoubleClick for Publishers API Forum
Hi Vincent, 

1) I checked the firewall, there are only accepting rules, there is no any Drop/Reject rule. 
2) Yes, I run the file in the command line. 
3) I do have a vendor folder in my public_html, it was created after that I uploaded the API source files and then using composer in the command line I run "composer install composer.json". So it added the Vendor folder and its dependencies inside. But I have also tried another installation way so that the API's source files are inside Vendor folder. So in this case it shows the AdsSoapClient error is in the path: /home/joni/web/glob.space/public_html/joni/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/AdsSoapClient.php on line 65

4) Not sure if it's possible to run Composer on the computer without using Xampp. Because it's Xampp that turns on the Apache and Php on the computer.

Thank you.

geob...@gmail.com

unread,
Feb 3, 2017, 4:17:06 AM2/3/17
to Google's DoubleClick for Publishers API Forum
Hello guys,
Finally, I did it. In the google console I created "other" type Client ID, then I generated an access token from GetRefreshToken.php, added to adsapi_php.ini, then put it in the home directory, and then running my lineitems.php from the console. I did everything using non-root server user. So, that's all. :) Now it works.

Thanks for the help!
Reply all
Reply to author
Forward
0 new messages