我们有一个应用程序依赖Google根据我们的谷歌应用程序帐户验证其用户,然后进行一些服务器端验证和组查找.
最近谷歌改变了持有access_token变量的对象的名称,我们需要对其进行身份验证.在文档(https://developers.google.com/identity/sign-in/web/reference#googleusergetbasicprofile)中,它表示access_token可以从getAuthResponse()方法获得,但是当我使用它时,它会以未定义的形式返回.在console.log()之后检查对象会显示除access_token之外的所有其他字段.我担心谷歌将来会再次改变这个对象而没有我们的申请就离开了我们.这是代码.
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<meta name="google-signin-client_id" content="XXX.apps.googleusercontent.com">
<script>
//This happens after the user has authenticated with Google and has been passed
//back to the page
function onSignIn(googleUser) {
//Check to see whether the user is trying to sign out.
if (window.location.href.indexOf("signOut=1") !== -1) {
//Sign them out of the application.
signOut();
//redirect them to the same page, without the signOut query string so they can log back in …Run Code Online (Sandbox Code Playgroud) 我创建了一个新的页面类型,需要分解内容.我创建了一个我想在页面上的3个位置使用的带状块,但是我想创建仅1个版本的带状块并通过动态数据驱动该内容.
我在Straplines.php中有以下内容
class Straplines extends DataObject{
private static $db = array(
'Title'=>'Text',
'Content'=>'HTMLText',
'SortOrder'=>'Int'
);
private static $has_one = array(
'Parent'=>'Page'
);
private static $default_sort = 'SortOrder';
public function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Main", new HtmlEditorField('Content','Content'));
$fields->addFieldToTab("Root.Main", new TextField('Title','Title'));
return $fields;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将cms字段添加到HomePage.php.我可以添加表带没有问题,他们都出现了.然后在HomePage.ss我有以下内容
<% include PricesBlock %>
<% include TourStraplineBlock %>
<% include QuickFacts %>
<% include TourStraplineBlock %>
Run Code Online (Sandbox Code Playgroud)
但是后来我无法在TourStraplineBlock中弄清楚为每个内容获取单独的内容.当然必须有参数化包含或不必创建多个模板.我对Silverstripe dev很新,并且发现创建可重用内容是一个艰难的过程.
编辑:这是处理显示的strapline.ss模板.
<div class="strapline">
<% loop Straplines %>
$Content
<% end_loop%>
</div>
Run Code Online (Sandbox Code Playgroud)
正如你可能猜到的那样,如果我把它放在两次,它只是显示所有的标语.我想做点什么
<% include Strapline?id=1 %>
Run Code Online (Sandbox Code Playgroud)
然后在Strapline.ss中解码并从那里开始.
编辑抱歉是的3.2不是3.0.我以为它们非常相似.
我有一些问题从PHP消耗wsHttpBinding WCF.我最初尝试使用SOAP1.2,但无法指定WS Action.
我下载了nusoap库.我最初收到一个错误,说由于类型不匹配(text/xml而不是预期的application/soap + xml),webservice不会接受数据.我设法对nusoap.php进行了更改,以将数据作为application/soap + xml发送.现在,这不会引发错误,我从服务器得到400错误的请求错误.
我可以从WCFTestClient和SOAPUI中使用服务而不会有任何麻烦,但是无法让它从PHP中传播.我甚至从SOAPUI复制了整个soap信封,并将nusoap.php中的$ soapmsg设置为完全相同,但它仍然失败.
所以任何人都想提供一些指导.
编辑 这是我在SOAP 1.2中尝试的代码
$params = array("soap_version"=> SOAP_1_2,
"trace"=>1,
"exceptions"=>0,
);
$client = @new SoapClient('https://localhost/wcftest/Service.svc?wsdl',$params);
$retval = $client->GetData(array('value'=>'stuff'));
if (is_soap_fault($retval)) {
trigger_error("SOAP Fault: (faultcode: {$retval->faultcode}, faultstring: {$retval->faultstring})", E_USER_ERROR);
}
Run Code Online (Sandbox Code Playgroud)
编辑#2这是用于SOAPUI的代码
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://tempuri.org/IService/GetData</wsa:Action></soap:Header>
<soap:Body>
<tem:GetData>
<!--Optional:-->
<tem:value>stuff</tem:value>
</tem:GetData>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
在按照下面的Gords链接提到的手动添加SoapHeaders后,我在使用netbeans进行调试时将其作为__last_request并仍然出现相同的错误
"<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/">
<env:Header>
<ns1:Action>http://tempuri.org/IService/GetData</ns1:Action>
</env:Header>
<env:Body><ns1:GetData><ns1:value>stuff</ns1:value></ns1:GetData></env:Body></env:Envelope>
Run Code Online (Sandbox Code Playgroud)
任何建议?
谢谢!安迪
我有一个检查在数组中是否找到值的函数。我想返回一个真或假。当前代码可以正常工作,但会引发js-standerd / es-lint错误“在条件表达式中不必要地使用布尔文字”我在这里搜索了很多错误消息,但似乎无法解决。对我来说,这是“如果找到该值,则返回true,否则返回false”
let found = value.find(val => {
return val === item
})
return found ? true : false
Run Code Online (Sandbox Code Playgroud)
我试过了
return value.find(val => {
return val === item
}) || false
Run Code Online (Sandbox Code Playgroud)
哪个可行,但如果找到则不返回布尔值,它返回item。
我知道我可以通过多种方式进行这项工作,但我只是想弄清楚我的代码是错误的还是不正确的,或者es-lint是否将其标记为错误的。
我觉得我在这里错过了一些东西.我有一个抓取一些数据的服务.我将其转换为承诺,然后尝试以单独的方法处理数据.
一旦它击中了方法,我就失去了访问我通常会从此访问的对象的能力.无论如何.如果我将addJobsToTree中的所有代码保留在then块中,它可以正常工作.我也可以从组件中的其他位置访问它.我确定我做的事情是愚蠢但却无法理解.
ngOnInit(){
this._scheduleDataService.getSavedScheduleData(this.buildDateStringFromCalendar(),1004)
.toPromise()
.then(this.addToJobsTree);
}
private addToJobsTree(res){
for(let xx of res){
this._sharedService.jobs.push(xx); //Comes back as cannot read _sharedService of null
console.log(this._sharedService.jobs);
}
}
Run Code Online (Sandbox Code Playgroud) javascript ×3
php ×2
angular ×1
eslint ×1
google-api ×1
google-oauth ×1
nusoap ×1
promise ×1
silverstripe ×1
ssl ×1
wcf ×1