在访问此Stripe API阵列的特定部分时遇到一些麻烦。我仍在学习使用这种模式,并且API会定期更新,但是此特定ID位于数组中,我以某种方式无法弄清楚如何访问,这就是我到目前为止所拥有的...
$subscriptions = \Stripe\Subscription::all(array('limit'=>100));
foreach($subscriptions->data as $subscription){
$sub_id = $subscription->id;
$sub_name = $subscription->plan->nickname;
$sub_item_id = $subscription->items;
print_r($sub_item_id);
}
此脚本输出以下内容:
Stripe\Collection Object ( [object] => list [data] => Array ( [0] => Stripe\SubscriptionItem Object ( [id] => si_DTLvqerPBwHgZ0 [object] => subscription_item [created] => 1535055364 [metadata] => Stripe\StripeObject Object ( ) [plan] => Stripe\Plan Object ( [id] => hithost [object] => plan [active] => 1 [aggregate_usage] => sum [amount] => [billing_scheme] => tiered [created] => 1535054527 [currency] => gbp [interval] => month [interval_count] => 1 [livemode] => 1 [metadata] => Stripe\StripeObject Object ( ) [nickname] => HitHost [product] => prod_DTLdxcoAqBC6HS [tiers] => Array ( [0] => Stripe\StripeObject Object ( [amount] => 300 [up_to] => 1 ) [1] => Stripe\StripeObject Object ( [amount] => 2 [up_to] => ) ) [tiers_mode] => graduated [transform_usage] => [trial_period_days] => [usage_type] => metered ) [subscription] => sub_DTLv0tZNFaQSEf ) ) [has_more] => [total_count] => 1 [url] => /v1/subscription_items?subscription=sub_DTLv0tZNFaQSEf )
我尝试访问的是[id] => si_DTLvqerPBwHgZ0
,我尝试了以下操作,但出现错误或黑屏。
$sub_item_id = $subscription->items->list;
$sub_item_id = $subscription->items->object->list;
$sub_item_id = $subscription->items->object->list[data];
有人可以在这里指出正确的方向吗?
答案 0 :(得分:1)
我认为您想要的是
//override stroke rendering for constant stroke width independent of scaling
fabric.Image.prototype._renderStroke = function(ctx) {
if (!this.stroke || this.strokeWidth === 0) {
return;
}
if (this.shadow && !this.shadow.affectStroke) {
this._removeShadow(ctx);
}
ctx.save();
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
this._setLineDash(ctx, this.strokeDashArray, this._renderDashedStroke);
this._applyPatternGradientTransform(ctx, this.stroke);
ctx.stroke();
ctx.restore();
};
//modify method for calculating control and bounding box positions
fabric.Image.prototype._getTransformedDimensions = function(skewX, skewY) {
if (typeof skewX === 'undefined') {
skewX = this.skewX;
}
if (typeof skewY === 'undefined') {
skewY = this.skewY;
}
var dimensions = this._getNonTransformedDimensions();
if (skewX === 0 && skewY === 0) {
return {
x: dimensions.x * this.scaleX + (this.strokeWidth * (1 - this.scaleX)),
y: dimensions.y * this.scaleY + (this.strokeWidth * (1 - this.scaleY))
};
}
var dimX = dimensions.x / 2,
dimY = dimensions.y / 2,
points = [{
x: -dimX,
y: -dimY
},
{
x: dimX,
y: -dimY
},
{
x: -dimX,
y: dimY
},
{
x: dimX,
y: dimY
}
],
i, transformMatrix = this._calcDimensionsTransformMatrix(skewX, skewY, false),
bbox;
for (i = 0; i < points.length; i++) {
points[i] = fabric.util.transformPoint(points[i], transformMatrix);
}
bbox = fabric.util.makeBoundingBoxFromPoints(points);
return {
x: bbox.width,
y: bbox.height
};
};
如果使用var_export
而不是$sub_item_id = $subscription->items->data[0]->id
,则调试这些问题会更容易,因为它会为变量创建有效的PHP代码,然后可在phptester.net等网站上使用。