This seems to be highly illogical, but I'm working on a web-shop and I'm trying to grab a package/item display name using the IP.Nexus API (not important).
This is part of the array returned by the invoice script:
invoice Object
(
[data:invoice:private] => Array
(
[i_status] => pend
[i_title] => BETA Tag, ALPHA Tag
[i_member] => 1
[i_items] => Array
(
[0] => Array
(
[act] => new
[app] => nexus
[type] => product
[cost] => 0
[tax] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[quantity] => 1
[physical] =>
[shipping] => Array
(
)
[subscription] =>
[weight] => 0
[itemName] => BETA Tag
Surely, to grab itemName, I would use,
$invoice['i_items'][0]['itemName']
Though for some strange reason, that isn't working.
Am I missing something?
Based on your information, you are trying to access a private data member. You need to use the public interface for the class invoice.
Related
I send "https://openapi.etsy.com/v2/listings/listing_id/inventory" but i received error "price must be consistent across all products"
that's what i give in offerings:
[offerings] => Array
(
[0] => Array
(
[price] => Array
(
[amount] => 14500
[divisor] => 100
[currency_code] => USD
[currency_formatted_short] => $145.00
[currency_formatted_long] => $145.00 USD
[currency_formatted_raw] => 145.00
)
[quantity] => 7
[is_enabled] => 1
[is_deleted] => 0
)
)
I had the same problem, and you also have to add the parameter [price_on_property], even if Etsy Api say it's optional.
When you are trying to update inventory, you don't include the entire Money object as json. The price is supplied as a double value only. (ex. "price=29.99")
It would look more like this
[offerings] => Array
(
[0] => Array
(
[price] => 145.00
[quantity] => 7
[is_enabled] => 1
[is_deleted] => 0
)
)
Can someone help me with eTapestry API. I'm using applyDefinedValues Method . Documentation is here: https://www.blackbaudhq.com/files/etapestry/api/methods/applyDefinedValues.html
Everything works fine when updating fields that are defined as text, int or other values, but I don't know how to update multiselect type.
I tried to send data like this:
$dv1["value"] = array('Eclipses','Electional','Estoteric/Spritual/Occult');
but system updates as new value 'Array'?
eTapestry return values looks like this:
[18] => Array
(
[dataType] => 0
[displayType] => 2
[fieldName] => My Interests
[fieldRef] => 249.0.39428157
[value] => Electional
[valueRef] => 249.0.39782431
)
[19] => Array
(
[dataType] => 0
[displayType] => 2
[fieldName] => My Interests
[fieldRef] => 249.0.39428157
[value] => Estoteric/Spritual/Occult
[valueRef] => 249.0.39782420
)
........
[21] => Array
(
[dataType] => 0
[displayType] => 2
[fieldName] => My Interests
[fieldRef] => 249.0.39428157
[value] => Archetypal Cosmology
[valueRef] => 249.0.39782417
I want to retrieve quantities from this array.
invoice Object
(
[data:private] => Array
(
[i_status] => pend
[i_title] => 500 HLCoins , 500 HLCoins x8
[i_member] => 1
[i_items] => Array
(
[0] => Array
(
[act] => new
[app] => nexus
[type] => product
[cost] => 0
[tax] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[quantity] => 1
[physical] =>
[shipping] => Array
(
)
[weight] => 0
[itemName] => 500 HLCoins
[itemID] => 3
[cfields] => Array
(
)
[extra] =>
[opt_id] => 0
[associated] =>
[assocBought] =>
[groupRenewals] => 0
[methods] => Array
(
)
[k] => 0
[_tax] => 0
)
[1] => Array
(
[act] => new
[app] => nexus
[type] => product
[cost] => 0
[tax] => 0
[renew_term] => 0
[renew_units] =>
[renew_cost] => 0
[quantity] => 8
[physical] =>
[shipping] => Array
(
)
[weight] => 0
[itemName] => 500 HLCoins
[itemID] => 3
[cfields] => Array
(
)
[opt_id] => 0
[groupRenewals] => 0
[methods] => Array
(
)
[_tax] => 0
)
)
[i_total] => 0
[i_date] => 1347217384
[i_return_uri] =>
[i_paid] => 0
[i_status_extra] => a:1:{s:4:"type";s:4:"zero";}
[i_discount] => 0
[i_temp] =>
[i_ordersteps] => 0
[i_noreminder] => 1
[i_renewal_ids] => Array
(
)
[i_po] =>
[i_notes] =>
[i_shipaddress] =>
[i_id] => 229
)
[takeAction] => 1
)
I've tried a bunch of codes like $invoice->quantity, $invoice[1]->quantity, $this->$invoice->quantity, but none of them seem to display.
It still does not display at all, I tried to print_r and that is the array it gave me.
All the variables are private which means you cannot access them from outside the object. Check out the class definition for the invoice class. There should be some function to get the quantities from the object, or else you could add such a feature to the class.
The whole point of this is separation of concerns. The class may change in the future and possibly not use the same structure, therefore you should use object functions to access the properties, do not access them directly as variables.
You can read more on this subject in the manual or in a book about object-oriented programming.
Seems like all the data is in a private property. You cannot access it from outside directly.
Read the documentation for the class. It should have some method you can call, like getQuantity(), that'll get you the data. It depends on how the class was written and how it is supposed to be used.
The best way for me to explain this is to show you. Seems like a float() error in a 64bit system.
when i call /anotherfeed/feed or any page for that matter, posts with story_tags return some of the id's as a float error.
sample story tag with float error in id. [id] => 1.7153566624E+14
My question is, how do i fix this, or what am i doing wrong? all i am doing is looping in a foreach statement.
if($fvalue[story_tags]){
echo 'Tags: ';
$sTags=$fvalue[story_tags];
foreach ($sTags as $skey=>$svalue){
foreach ($svalue as $gkey=>$hvalue){
$id=$hvalue[id];
echo ''.$hvalue[name].' '.$id.' ';
}
}
}
[story_tags] => Array
(
[0] => Array
(
[0] => Array
(
[id] => 1.7153566624E+14
[name] => Another Feed
[offset] => 0
[length] => 12
[type] => page
)
)
Array
(
[data] => Array
(
[0] => Array
(
[id] => 171535666239724_156133294510726
[from] => Array
(
[name] => Another Feed
[category] => App page
[id] => 171535666239724
)
[story] => Another Feed shared Non-Profits on Facebook's photo.
[story_tags] => Array
(
[0] => Array
(
[0] => Array
(
[id] => 1.7153566624E+14
[name] => Another Feed
[offset] => 0
[length] => 12
[type] => page
)
)
[20] => Array
(
[0] => Array
(
[id] => 41130665917
[name] => Non-Profits on Facebook
[offset] => 20
[length] => 23
[type] => page
)
)
)
[picture] => http://photos-d.ak.fbcdn.net/hphotos-ak-ash3/557037_10150932300320918_1908237167_s.jpg
[link] => http://www.facebook.com/photo.php?fbid=10150932300320918&set=a.85612830917.95996.41130665917&type=1
[name] => Wall Photos
[caption] => Have you heard of the #[159208207468539:274:One Day without Shoes] (ODWS) campaign? ODWS is an annual initiative by #[8416861761:274:TOMS] to bring awareness around the impact a pair of shoes can have on a child's life.
During the 2012 campaign, #[20531316728:274:Facebook] drove 20% of traffic to the ODWS microsite and TOMS even launched a Facebook-exclusive "Barefoot & Blue" giveaway with #[25266987484:274:Essie Nail Polish] for the second year in a row.
We think this is a pretty cool example of creating exclusive content around an important initiative that keeps people engaged and involved!
[properties] => Array
(
[0] => Array
(
[name] => By
[text] => Non-Profits on Facebook
[href] => http://www.facebook.com/nonprofits
)
)
[icon] => http://static.ak.fbcdn.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif
[type] => photo
[object_id] => 10150932300320918
[application] => Array
(
[name] => Photos
[id] => 2305272732
)
[created_time] => 2012-07-02T17:57:23+0000
[updated_time] => 2012-07-02T17:57:23+0000
[comments] => Array
(
[count] => 0
)
)
solution:
cURL - had to use number format with PHP_EOL to solve in cURL.
// $locs = curl call to graph api for /anotherfeed/feed, still need solution for foreach.
$locs=json_decode($returned, true);
$stId=number_format($locs[data][1][story_tags][0][0][id], 0, '', '').PHP_EOL;
echo $stId;
PHP-SDK
solution is same, long numbers in the foreach loop need to be ran through number_format.
I am using the CakePHP framework. When returning the results of a query, the framework calls the "experimental" PDOStatement::getColumnMeta to "arrayify" the data when it comes back from the database. However, there are mixed results depending on the query.
There are times when the array of data comes back as expected where all columns are associated to the name of the view. Other times, the data comes back mixed, where some of the data sits in an array associated with the original table that corresponds to the view.
// correct
Array(
[MyInstall] => Array
(
[id] => a6d1342a-7b4d-11e1-8397-60195b7d6275
[user_id] => dc038c9e-7b4b-11e1-8397-60195b7d6275
[script_id] => 057de1e0-7b48-11e1-8397-60195b7d6275
[path] =>
[url] =>
[created] => 2009-06-15 12:43:30
[version] => 3.2.1
[admin_url] => wp-admin
[name] => WordPress
[icon] => icon_WordPress.gif
)
)
//incorrect
Array(
[MyInstall] => Array
(
[id] => c71a2368-7b4d-11e1-8397-60195b7d6275
[user_id] => dc038c9e-7b4b-11e1-8397-60195b7d6275
[path] =>
[url] =>
[created] => 2011-11-07 22:26:38
[version] => 3.2.1
[admin_url] => wp-admin
)
[Script] => Array
(
[script_id] => 057de1e0-7b48-11e1-8397-60195b7d6275
[name] => WordPress
[icon] => icon_WordPress.gif
)
)
The way the results are built is from the results of the PDOStatment::getColumnMeta. Here is what a sample result of getColumnMeta looks like:
Array
(
[native_type] => STRING
[pdo_type] => 2
[flags] => Array
(
[0] => not_null
)
[table] => MyInstall
[name] => id
[len] => 108
[precision] => 0
)
Any suggestions on how I can get this same information using PDO for MySQL? Or is there another solution to this problem?
BTW: I already filed a bug with the PHP folks on this.
As it turns out, this is a now known bug in MySQL: http://bugs.mysql.com/bug.php?id=66794, still pending at the time of writing.