Skip to content

Commit 8806a01

Browse files
author
attdevsupport
committed
OCT 07 2013 Sample app bug fixes
1 parent e8471c3 commit 8806a01

File tree

710 files changed

+39246
-8202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

710 files changed

+39246
-8202
lines changed

RESTFul/ADS/Csharp/app1/Default.aspx.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public partial class Ad_App1 : System.Web.UI.Page
4747
/// <summary>
4848
/// Application parameters.
4949
/// </summary>
50-
private string apiKey, secretKey, endPoint, scope;
50+
private string apiKey, secretKey, endPoint, scope, bypassSSL;
5151

5252
/// <summary>
5353
/// Access token file path
@@ -591,11 +591,17 @@ protected void Page_Load(object sender, EventArgs e)
591591

592592
private static void BypassCertificateError()
593593
{
594-
ServicePointManager.ServerCertificateValidationCallback +=
595-
delegate(Object sender1, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
596-
{
597-
return true;
598-
};
594+
string bypassSSL = ConfigurationManager.AppSettings["IgnoreSSL"];
595+
596+
if ((!string.IsNullOrEmpty(bypassSSL))
597+
&& (string.Equals(bypassSSL, "true", StringComparison.OrdinalIgnoreCase)))
598+
{
599+
ServicePointManager.ServerCertificateValidationCallback +=
600+
delegate(Object sender1, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
601+
{
602+
return true;
603+
};
604+
}
599605
}
600606

601607
private bool ReadConfigFile()

RESTFul/ADS/Csharp/app1/web.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<customErrors mode="Off"/>
1010
</system.web>
1111
<appSettings>
12+
13+
<!-- Set this parameter value to "true", if you need to bypass the SSL certificate. Default FALSE -->
14+
<add key="IgnoreSSL" value="false"/>
1215
<!-- This is mandatory key and value should be equal
1316
to Ads Service registered application 'API key'
1417
example: value=""-->

RESTFul/ADS/Java/app1/src/main/java/com/att/api/ads/controller/ADSController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import org.json.JSONObject;
1010

11+
import com.att.api.ads.model.ConfigBean;
1112
import com.att.api.ads.service.ADSService;
1213
import com.att.api.controller.APIController;
1314
import com.att.api.oauth.OAuthToken;
@@ -158,9 +159,9 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
158159
this.saveSession(request);
159160

160161
final String forward = "WEB-INF/ADS.jsp";
162+
request.setAttribute("cfg", new ConfigBean());
161163
RequestDispatcher dispatcher = request.getRequestDispatcher(forward);
162164
dispatcher.forward(request, response);
163-
164165
}
165166

166167
public void doGet(HttpServletRequest request, HttpServletResponse response)

RESTFul/ADS/PHP/app1/index.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
require __DIR__ . '/config.php';
33
require_once __DIR__ . '/src/Controller/ADSController.php';
44
require_once __DIR__ . '/lib/Util/Util.php';
5+
use Att\Api\Util\Util;
6+
57
$controller = new ADSController();
68
$controller->handleRequest();
79
$errors = $controller->getErrors();
@@ -253,16 +255,9 @@
253255
<?php
254256
if (is_string($result)) {
255257
echo htmlspecialchars($result);
256-
}
257258
?>
258259
</div>
259-
<?php if (is_array($result)) {
260-
$response = $result['AdsResponse'];
261-
$ads = $response['Ads'];
262-
$type = $ads['Type'];
263-
$clickURL = $ads['ClickUrl'];
264-
$content = $ads['Content'];
265-
?>
260+
<?php } else { ?>
266261
<table>
267262
<thead>
268263
<tr>
@@ -273,15 +268,15 @@
273268
<tbody>
274269
<tr>
275270
<td data-value="Parameter">Type</td>
276-
<td data-value="Value"><?php echo htmlspecialchars($type); ?></td>
271+
<td data-value="Value"><?php echo htmlspecialchars($result->getAdsType()); ?></td>
277272
</tr>
278273
<tr>
279274
<td data-value="Parameter">ClickUrl</td>
280-
<td data-value="Value"><?php echo htmlspecialchars($clickURL); ?></td>
275+
<td data-value="Value"><?php echo htmlspecialchars($result->getClickUrl()); ?></td>
281276
</tr>
282277
</tbody>
283278
</table>
284-
<?php echo $content; ?>
279+
<?php echo $result->getContent(); ?>
285280

286281
<?php } ?>
287282
<?php } ?>
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<?php
2+
namespace Att\Api\ADS;
3+
4+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 */
5+
6+
/**
7+
* ADS Library
8+
*
9+
* PHP version 5.4+
10+
*
11+
* LICENSE: Licensed by AT&T under the 'Software Development Kit Tools
12+
* Agreement.' 2013.
13+
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTIONS:
14+
* http://developer.att.com/sdk_agreement/
15+
*
16+
* Copyright 2013 AT&T Intellectual Property. All rights reserved.
17+
* For more information contact developer.support@att.com
18+
*
19+
* @category API
20+
* @package ADS
21+
* @author pk9069
22+
* @copyright 2013 AT&T Intellectual Property
23+
* @license http://developer.att.com/sdk_agreement AT&amp;T License
24+
* @link http://developer.att.com
25+
*/
26+
27+
/**
28+
* Immutable class used to contain an ADSResponse.
29+
*
30+
* For a list of response values and their definitions, refer to
31+
* {@link https://developer.att.com/docs/apis/rest/1/Advertising}.
32+
*
33+
* @category API
34+
* @package ADS
35+
* @author pk9069
36+
* @license http://developer.att.com/sdk_agreement AT&amp;T License
37+
* @version Release: @package_version@
38+
* @link https://developer.att.com/docs/apis/rest/1/Advertising
39+
*/
40+
final class ADSResponse
41+
{
42+
43+
/**
44+
* Click Url.
45+
*
46+
* @var string
47+
*/
48+
private $_clickUrl;
49+
50+
/**
51+
* Type of advertisement.
52+
*
53+
* @var string
54+
*/
55+
private $_type;
56+
57+
/**
58+
* Image Url, if any.
59+
*
60+
* @var string
61+
*/
62+
private $_imageUrl;
63+
64+
/**
65+
* Track Url, if any.
66+
*
67+
* @var string
68+
*/
69+
private $_trackUrl;
70+
71+
/**
72+
* Ad content, if any.
73+
*
74+
* @var string
75+
*/
76+
private $_content;
77+
78+
79+
/**
80+
* Creates an object that encapsulates an ADS response.
81+
*
82+
* @param string $clickUrl click url
83+
* @param string $type ads type
84+
* @param string $imageUrl image url, if any
85+
* @param string $trackUrl track url, if any
86+
* @param string $content content, if any
87+
*/
88+
public function __construct($clickUrl, $type, $imageUrl = null,
89+
$trackUrl = null, $content = null
90+
) {
91+
$this->_clickUrl = $clickUrl;
92+
$this->_type = $type;
93+
94+
$this->_imageUrl = $imageUrl;
95+
$this->_trackUrl = $trackUrl;
96+
$this->_content = $content;
97+
}
98+
99+
/**
100+
* Gets the click url.
101+
*
102+
* @return string click url
103+
*/
104+
public function getClickUrl()
105+
{
106+
return $this->_clickUrl;
107+
}
108+
109+
/**
110+
* Gets the type of ad.
111+
*
112+
* @return string ad type
113+
*/
114+
public function getAdsType()
115+
{
116+
return $this->_type;
117+
}
118+
119+
/**
120+
* Gets the image url, if any.
121+
*
122+
* @return string|null image url or null if none
123+
*/
124+
public function getImageUrl()
125+
{
126+
return $this->_imageUrl;
127+
}
128+
129+
/**
130+
* Gets the track url, if any.
131+
*
132+
* @return string|null track url or null if none
133+
*/
134+
public function getTrackUrl()
135+
{
136+
return $this->_trackUrl;
137+
}
138+
139+
/**
140+
* Gets content, if any.
141+
*
142+
* @return string|null content or null if none
143+
*/
144+
public function getContent()
145+
{
146+
return $this->_content;
147+
}
148+
149+
/**
150+
* Createa an ADSResponse object from the specified array.
151+
*
152+
* @param array $arr array to use for creating an ADSResponse object
153+
*
154+
* @return ADSResponse ADSResponse object
155+
* @throws ServiceException if array contains unexpected values
156+
*/
157+
public static function fromArray($arr)
158+
{
159+
$adsResponse = $arr['AdsResponse'];
160+
$ads = $adsResponse['Ads'];
161+
162+
// required response values
163+
$required = array('ClickUrl', 'Type');
164+
foreach ($required as $value) {
165+
if (!isset($ads[$value])) {
166+
$msg = "Required field '$value' not set.";
167+
$httpCode = $result->getResponseCode();
168+
throw new ServiceException($msg, $httpCode);
169+
}
170+
}
171+
172+
$type = $ads['Type'];
173+
$clickUrl = $ads['ClickUrl'];
174+
175+
// optional response values
176+
$imgUrl = isset($ads['ImageUrl']) ? $ads['ImageUrl'] : null;
177+
$trackUrl = isset($ads['TrackUrl']) ? $ads['TrackUrl'] : null;
178+
$content = isset($ads['Content']) ? $ads['Content'] : null;
179+
180+
return new ADSResponse($clickUrl, $type, $imgUrl, $trackUrl, $content);
181+
}
182+
183+
}
184+
185+
?>

0 commit comments

Comments
 (0)