how to replace sub array - php

i get json in my project and then i have replace some sub array of it and again have to pass it. so, when i decode json and display it with pre tag it's display like this.
Array
(
[callid] => 59538ea658dfa
[action] => config_get
[message] => ok
[data] => Array
(
[config_file] => /cf/conf/config.xml
[config] => Array
(
[filter] => Array
(
[separator] => Array
(
[wan] =>
)
[rule] => Array
(
[0] => Array
(
[id] =>
[tracker] => 1498479412
[type] => pass
[interface] => wan
[ipprotocol] => inet
[tag] =>
[tagged] =>
[max] =>
[max-src-nodes] =>
[max-src-conn] =>
[max-src-states] =>
[statetimeout] =>
[statetype] => keep state
[os] =>
[protocol] => tcp
[source] => Array
(
[any] =>
)
[destination] => Array
(
[any] =>
)
[descr] => Hi manoj2
[updated] => Array
(
[time] => 1498479412
[username] => admin#172.16.1.22
)
[created] => Array
(
[time] => 1498479412
[username] => admin#172.16.1.22
)
)
[1] => Array
(
[statetype] => keep state
[statetimeout] =>
[max-src-states] =>
[max] =>
[tagged] =>
[tag] =>
[ipprotocol] => inet
[interface] => wan
[os] =>
[source] => Array
(
[any] =>
)
[destination] => Array
(
[any] =>
)
[descr] => hi Divyesh
[updated] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[created] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[type] => pass
[tracker] => 1498301528
[id] =>
[max-src-nodes] =>
[max-src-conn] =>
)
[2] => Array
(
[destination] => Array
(
[any] =>
)
[source] => Array
(
[network] => lan
)
[tracker] => 0100000101
[interface] => lan
[descr] => Default allow LAN to any rule
[ipprotocol] => inet
[type] => pass
)
[3] => Array
(
[destination] => Array
(
[any] =>
)
[source] => Array
(
[network] => lan
)
[tracker] => 0100000102
[interface] => lan
[descr] => Default allow LAN IPv6 to any rule
[ipprotocol] => inet6
[type] => pass
)
)
)
[shaper] =>
[ipsec] =>
[aliases] => Array
(
[alias] => Array
(
[0] => Array
(
[name] => manoj2_alias2
[type] => network
[address] => manoj2_alias3 172.30.2.65/16 172.30.2.51/32
[descr] => descc
[detail] => nfvbg||dfg||asd | asdfg
)
[1] => Array
(
[name] => manoj2_alias3
[type] => host
[address] => tyuty tyu
[descr] => dess
[detail] => tyu||tyu
)
[2] => Array
(
[name] => sdf
[type] => network
[address] => manoj2_alias2
[descr] => afsasf || weriojdg
[detail] => 256418
)
)
)
)
)
)
and i want to just replace portion sub array of [rule] with the.
[rule] => Array
(
[0] => Array
(
[id] =>
[tracker] => 1498479412
[type] => block
[interface] => lan
[ipprotocol] => any
[tag] =>
[tagged] =>
[max] =>
[max-src-nodes] =>
[max-src-conn] =>
[max-src-states] =>
[statetimeout] =>
[statetype] => keep state
[os] =>
[protocol] => tcp/udp
[source] => Array
(
[any] =>
)
[destination] => Array
(
[any] =>
)
[descr] => second option
[updated] => Array
(
[time] => 149844356
[username] => admin#172.16.1.22
)
[created] => Array
(
[time] => 1498479412
[username] => admin#172.16.1.22
)
)
[1] => Array
(
[statetype] => keep state
[statetimeout] =>
[max-src-states] =>
[max] =>
[tagged] =>
[tag] =>
[ipprotocol] => single
[interface] => wan
[os] =>
[source] => Array
(
[any] => 172.31.2.65/24
)
[destination] => Array
(
[any] => manoj2_alias2
)
[descr] => first option
[updated] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[created] => Array
(
[username] => admin#192.168.1.100
[time] => 1498301528
)
[type] => pass
[tracker] => 1498301528
[id] =>
[max-src-nodes] =>
[max-src-conn] =>
)
)
how to do it please help me. i tried but not any success.

Access your array element and assign the new array to it.
$array['data']['config']['filter']['rule'] = $theNewRuleArray;

Related

How to retrieve object from xml

I am trying to get the value of bank_name in php. Can't get it to display.
stdClass Object ( [account_id] => 43726384 [name] => Account Name [state] => action_required [description] => [owner_user_id] =>[type] => personal [create_time] => 1477684534 [disablement_time] => [country] => US [currencies] => Array ( [0] => USD ) [action_reasons] => Array ( [0] => kyc [1] => bank_account ) [disabled_reasons] => Array ( ) [image_uri] => [supported_card_types] => Array ( [0] => visa [1] => mastercard [2] => american_express [3] => discover [4] => jcb [5] => diners_club ) [gaq_domains] => Array ( [0] => ) [balances] => Array ( [0] => stdClass Object ( [balance] => 0 [currency] => USD [disputed_amount] => 0 [incoming_pending_amount] => 0 [outgoing_pending_amount] => 0 [reserved_amount] => 0 [bank_name] => Bank Of America [withdrawal_next_time] => [withdrawal_period] => [withdrawal_type] => ) ) [statuses] => Array ( [0] => stdClass Object ( [currency] => USD [incoming_payments_status] => ok [outgoing_payments_status] => paused [account_review_status] => not_requested ) ) )
It's not very clear if you display data that way, but I think this would be the way to access to bank_name:
$bankName = $object->balances[0]->bank_name;
(If it doesn't work, please show the XML before parsing it to an object)

How to process complex json object in PHP

I have a working PHP app running in Bluemix that I want to extend to call a RESTful service (Insights for Twitter). I've been able to call the service, retrieve the json body, and use json_decode as follows to create an array:
$insightList = json_decode($guzzleResponse ->getBody(), true);
However, I can't figure out how to get access to the field I'm interested in. I've searched for solution on the web and tried a few approaches that looked promising, but when I tried to integrate them, I couldn't get them to work. I'm a bit of a PHP novice, so if something doesn't work I'm not sure how to proceed.
The json structure is quite complex, with three top-level arrays - search, tweets, and next. I'm interested in the second of these, tweets. It's a pretty complex array - there is one entry per tweet. The field I want right now is tweets.cde.message.body. You can find the full schema here: https://cdeservice.eu-gb.mybluemix.net/rest-api/#!/messages/getTweets
This is the code I have so far:
foreach($insightList as $cde) {
foreach($cde as $message) {
$insight = $message['body'];
if(strlen($insight) > 60) {
$posts[] = array(
'id' => 99999999,
//Temp; remove links from the text
'text' => $insight,
'category' => $insightCategory,
'image' => 'false'
);
}
}
}
Here's a print_r of $insightList:
[search] => Array (
[results] => 28
[current] => 28
)
[tweets] => Array (
[0] => Array (
[cde] => Array (
[author] => Array (
[gender] => male
[parenthood] => Array (
[isParent] => unknown
)
[location] => Array (
[country] =>
)
[maritalStatus] => Array (
[isMarried] => unknown
)
)
[content] => Array (
[sentiment] => Array (
[evidence] => Array ( )
[polarity] => NEUTRAL
)
)
)
[message] => Array (
[postedTime] => 2015-01-13T09:42:16.000Z
[verb] => share
[link] => http://twitter.com/zWDOM/statuses/554936456477933569
[generator] => Array (
[displayName] => Twitter Web Client
[link] => http://twitter.com
)
[body] => RT #VisualSuccess: "Mainframe & Cloud" Magazine wurde soeben publiziert! http://www.twitter.com #zWDOM #Rocket #JohnKnutson_IBM
[favoritesCount] => 0
[objectType] => activity
[actor] => Array (
[summary] => Seit über 25 Jahren im Mainframebereich, derzeit als Senior Consultant und IT Architekt für zEnterprise und Projektmanager beim IBM BP Cancom in Köln
[image] => https://pbs.twimg.com/profile_images/424202233463308288/XQquUcnh_normal.jpeg
[statusesCount] => 2309
[utcOffset] => 3600
[languages] => Array (
[0] => de
)
[preferredUsername] => zWDOM
[displayName] => Willi Domroese
[postedTime] => 2009-12-17T01:39:25.000Z
[link] => http://www.twitter.com/zWDOM
[verified] =>
)
[provider] => Array (
[displayName] => Twitter
[link] => http://www.twitter.com
[objectType] => service
)
[twitter_filter_level] => medium
[twitter_entities] => Array (
[urls] => Array (
[0] => Array (
[display_url] => ln.is/paper.li/visua…
[indices] => Array (
[0] => 77
[1] => 99
)
[expanded_url] => http://ln.is/paper.li/visualsucce/7zYNk
[url] => http://www.twitter.com
)
)
[hashtags] => Array ( )
[user_mentions] => Array (
[0] => Array (
[indices] => Array (
[0] => 3
[1] => 17
)
[screen_name] => VisualSuccess
[id_str] => 213337792
[name] => Predrag Gasic
[id] => 213337792
)
[1] => Array (
[indices] => Array (
[0] => 101
[1] => 107
)
[screen_name] => zWDOM
[id_str] => 97334013
[name] => Willi Domroese
[id] => 97334013
)
[2] => Array (
[indices] => Array (
[0] => 108
[1] => 115
)
[screen_name] => Rocket
[id_str] => 870584947
[name] => Rocket Software
[id] => 870584947
)
[3] => Array (
[indices] => Array (
[0] => 116
[1] => 132
)
[screen_name] => JohnKnutson_IBM
[id_str] => 16452310
[name] => John Knutson
[id] => 16452310
)
)
[trends] => Array ( )
[symbols] => Array ( )
)
[twitter_lang] => de
[id] => tag:search.twitter.com,2005:554936456477933569
[retweetCount] => 1
[gnip] => Array (
[urls] => Array (
[0] => Array (
[expanded_url] => http://linkis.com/paper.li/visualsucce/7zYNk
[expanded_status] => 200
[url] => http://www.twitter.com
)
)
[language] => Array (
[value] => de
)
)
[object] => Array (
[postedTime] => 2015-01-13T08:04:48.000Z
[verb] => post
[link] => http://twitter.com/VisualSuccess/statuses/554911928527888384
[generator] => Array (
[displayName] => Linkis.com
[link] => http://linkis.com
)
[body] => "Mainframe & Cloud" Magazine wurde soeben publiziert! http://www.twitter.com ://www.twitter.com
[objectType] => activity
[actor] => Array (
[summary] => Ù† (N), Wirtschaftsinformatiker | SAP Consultant Logistics #bigdata #appdevelopment #webdesign #eCommerce #SocialMedia #contentmarketing #SmartHome #Journal
[image] => https://pbs.twimg.com/profile_images/2841607223/959b0d23646b1f24bd7b70deac160e2f_normal.jpeg
[statusesCount] => 14185
[utcOffset] => 3600
[languages] => Array (
[0] => de
)
[preferredUsername] => VisualSuccess
[displayName] => Predrag Gasic
[postedTime] => 2010-11-08T17:19:27.000Z
[link] => http://www.twitter.com/VisualSuccess
[verified] =>
)
[provider] => Array (
[displayName] => Twitter
[link] => http://www.twitter.com
[objectType] => service
)
[twitter_filter_level] => low
[twitter_entities] => Array (
[urls] => Array (
[0] => Array (
[display_url] => ln.is/paper.li/visua…
[indices] => Array (
[0] => 58
[1] => 80
)
[expanded_url] => http://ln.is/paper.li/visualsucce/7zYNk
[url] => http://www.twitter.com
)
)
[hashtags] => Array ( )
[user_mentions] => Array (
[0] => Array (
[indices] => Array (
[0] => 82
[1] => 88
)
[screen_name] => zWDOM
[id_str] => 97334013
[name] => Willi Domroese
[id] => 97334013
)
[1] => Array (
[indices] => Array (
[0] => 89
[1] => 96
)
[screen_name] => Rocket
[id_str] => 870584947
[name] => Rocket Software
[id] => 870584947
)
[2] => Array (
[indices] => Array (
[0] => 97
[1] => 113
)
[screen_name] => JohnKnutson_IBM
[id_str] => 16452310
[name] => John Knutson
[id] => 16452310
)
)
[trends] => Array ( )
[symbols] => Array (
)
)
)
)
)
Answers to this question would be greatly appreciated
Iterating $insightList will not get you to the cde level. And you don't actually want the cde; you want the message.
Just iterate the tweets. You don't need a foreach to get keyed info from a PHP array.
foreach($insightList['tweets'] as $tweet) {
$insight = $tweet['message']['body'];
if(strlen($insight) > 60) {
$posts[] = array(
'id' => 99999999,
//Temp; remove links from the text
'text' => $insight,
'category' => $insightCategory,
'image' => 'false'
);
}
}
It looks to me from your print_r that what you want is at:
echo $insightList[0]['message']['body'];
When there's a section like this [some_key], then 'some_key' is an associative array key, and you can access those elements be they additional arrays or a value, using the key name, as I illustrated here.

How can I access the facebook books.reads's title using php?

How can I to have access to the "title" or "id" of my books in /me/books.reads (via graph api explorer I can see it, but not fetch it for my app).
I,ve trying
$books = $facebook->api('/me/book.reads','GET' );
foreach($books['data'] as $book) {
echo $book;
}
but doesn't work.
What I need to do?
UPDATE
Using print_r ($book);
Array ( [id] => 1404041189817636 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-11T05:23:56+0000 [publish_time] => 2013-08-11T05:23:56+0000 [application] => Array ( [name] => Books [id] => 174275722710475 ) [data] => Array ( [book] => Array ( [id] => 103118839728079 [url] => https://www.facebook.com/pages/O-alienista/103118839728079 [type] => books.book [title] => O alienista ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1402725673282521 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-08T12:06:56+0000 [end_time] => 2013-08-08T12:06:56+0000 [publish_time] => 2013-08-08T12:06:56+0000 [application] => Array ( [name] => cultdynamo-alfa [namespace] => cultdynamoalfa [id] => 486466824776147 ) [data] => Array ( [book] => Array ( [id] => 10151106849476668 [url] => http://samples.ogp.me/344468272304428 [type] => books.book [title] => Snow Crash ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1402724833282605 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-08T12:05:28+0000 [end_time] => 2013-08-08T12:05:28+0000 [publish_time] => 2013-08-08T12:05:28+0000 [application] => Array ( [name] => cultdynamo-alfa [namespace] => cultdynamoalfa [id] => 486466824776147 ) [data] => Array ( [book] => Array ( [id] => 10151106849476668 [url] => http://samples.ogp.me/344468272304428 [type] => books.book [title] => Snow Crash ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1402724089949346 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-08T12:02:20+0000 [end_time] => 2013-08-08T12:02:20+0000 [publish_time] => 2013-08-08T12:02:20+0000 [application] => Array ( [name] => cultdynamo-alfa [namespace] => cultdynamoalfa [id] => 486466824776147 ) [data] => Array ( [book] => Array ( [id] => 10151106849476668 [url] => http://samples.ogp.me/344468272304428 [type] => books.book [title] => Snow Crash ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1402724086616013 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-08T12:02:17+0000 [end_time] => 2013-08-08T12:02:17+0000 [publish_time] => 2013-08-08T12:02:17+0000 [application] => Array ( [name] => cultdynamo-alfa [namespace] => cultdynamoalfa [id] => 486466824776147 ) [data] => Array ( [book] => Array ( [id] => 10151106849476668 [url] => http://samples.ogp.me/344468272304428 [type] => books.book [title] => Snow Crash ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1402724056616016 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-08T12:02:05+0000 [end_time] => 2013-08-08T12:02:05+0000 [publish_time] => 2013-08-08T12:02:05+0000 [application] => Array ( [name] => cultdynamo-alfa [namespace] => cultdynamoalfa [id] => 486466824776147 ) [data] => Array ( [book] => Array ( [id] => 10151106849476668 [url] => http://samples.ogp.me/344468272304428 [type] => books.book [title] => Snow Crash ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1402246609997094 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-07T15:06:54+0000 [end_time] => 2013-08-07T15:06:54+0000 [publish_time] => 2013-08-07T15:06:54+0000 [application] => Array ( [name] => cultdynamo-alfa [namespace] => cultdynamoalfa [id] => 486466824776147 ) [data] => Array ( [book] => Array ( [id] => 10151106849476668 [url] => http://samples.ogp.me/344468272304428 [type] => books.book [title] => Snow Crash ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1402246209997134 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-07T15:05:16+0000 [end_time] => 2013-08-07T15:05:16+0000 [publish_time] => 2013-08-07T15:05:16+0000 [application] => Array ( [name] => cultdynamo-alfa [namespace] => cultdynamoalfa [id] => 486466824776147 ) [data] => Array ( [book] => Array ( [id] => 10151106849476668 [url] => http://samples.ogp.me/344468272304428 [type] => books.book [title] => Snow Crash ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1401338750087880 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-05T22:51:44+0000 [publish_time] => 2013-08-05T22:51:44+0000 [application] => Array ( [name] => Books [id] => 174275722710475 ) [data] => Array ( [book] => Array ( [id] => 10150941236166867 [url] => http://www.goodreads.com/book/show/13583337-clube-da-luta [type] => good_reads:book [title] => Clube da Luta ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1400891206799301 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-05T02:57:48+0000 [publish_time] => 2013-08-05T02:57:48+0000 [application] => Array ( [name] => Books [id] => 174275722710475 ) [data] => Array ( [book] => Array ( [id] => 10150604461117511 [url] => http://www.goodreads.com/book/show/6072069-cidade-de-deus [type] => good_reads:book [title] => Cidade De Deus ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1400890130132742 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-05T02:52:18+0000 [publish_time] => 2013-08-05T02:52:18+0000 [application] => Array ( [name] => Books [id] => 174275722710475 ) [data] => Array ( [book] => Array ( [id] => 108088695879860 [url] => https://www.facebook.com/pages/On-the-Road/108088695879860 [type] => books.book [title] => On the Road ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1400889916799430 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-05T02:51:27+0000 [publish_time] => 2013-08-05T02:51:27+0000 [application] => Array ( [name] => Books [id] => 174275722710475 ) [data] => Array ( [book] => Array ( [id] => 113172245363155 [url] => https://www.facebook.com/pages/Maus/113172245363155 [type] => books.book [title] => Maus ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) ) Array ( [id] => 1399682946920127 [from] => Array ( [name] => Inaldo Eleuterio [id] => 100006353053787 ) [start_time] => 2013-08-03T03:13:42+0000 [publish_time] => 2013-08-03T03:13:42+0000 [application] => Array ( [name] => Books [id] => 174275722710475 ) [data] => Array ( [book] => Array ( [id] => 108006402553308 [url] => https://www.facebook.com/pages/V-for-Vendetta/108006402553308 [type] => books.book [title] => V for Vendetta ) ) [type] => books.reads [no_feed_story] => [likes] => Array ( [count] => 0 [can_like] => 1 [user_likes] => ) [comments] => Array ( [count] => 0 [can_comment] => 1 [comment_order] => chronological ) )
You were basically improperly accessing the array. Based on the structure of the array, here's how you can access the title and id of the books:
$books = $facebook->api('/me/book.reads','GET' );
foreach ($books as $book)
{
echo "ID: ".$book['data']['book']['id'];
echo "Title: ".$book['data']['book']['title'];
}
Let me know if this works and makes sense to you :)

retrieving data from a php object

I am trying to access data inside a php object. I am confused about what the exact stynax is. Here is the output of the object:
stdClass Object ( [vid] => 10 [uid] => 1 [title] => Beachhead Don [log] =>
[status] => 1 [comment] => 1 [promote] => 0 [sticky] => 0 [ds_switch] => [nid] =>
10 [type] => product [language] => und [created] => 1357668665 [changed] => 1358198386
[tnid] => 0 [translate] => 0 [revision_timestamp] => 1358198386 [revision_uid] => 1
[model] => B 3000 [list_price] => 0.00000 [cost] => 0.00000 [sell_price] => 1.00000
[weight] => 0 [weight_units] => lb [length] => 0 [width] => 0 [height] => 0
[length_units] => in [pkg_qty] => 1 [default_qty] => 1 [unique_hash] =>
2eec0fcc8483f3a3541870fb24223296 [ordering] => 0 [shippable] => 0 [price] => 1.00000
[body] => Array ( [und] => Array ( [0] => Array ( [value] => Description info
))))))))))))))))))))))))))))))))))))))0 [summary] => [format] => filtered_html
[safe_value] =>Description info ))))))))))))))))))))))))))))))))))))))0[safe_summary]
=> ) ) ) [uc_product_image] => Array ( [und] => Array ( [0] => Array ( [fid] => 11
[alt] => [title] => [width] => 90 [height] => 120 [uid] => 1 [filename] =>
beachhead_don.jpg [uri] => public://beachhead_don.jpg [filemime] => image/jpeg
[filesize] => 14342 [status] => 1 [timestamp] => 1357668665 [rdf_mapping] => Array ( )
) ) ) [field_author] => Array ( [und] => Array ( [0] => Array ( [value] => John B.
Romesier [format] => [safe_value] => John B. Romesier ) ) ) [field_publisher] => Array
( [und] => Array ( [0] => Array ( [value] => Unknown [format] => [safe_value] =>
Unknown ) ) ) [field_release_date] => Array ( [und] => Array ( [0] => Array ( [value]
=> Mar 2012 [format] => [safe_value] => Mar 2012 ) ) ) [field_number_of_pages] => Array
( [und] => Array ( [0] => Array ( [value] => 123 ) ) ) [field_catagory] => Array (
[und] => Array ( [0] => Array ( [tid] => 4 ) ) ) [field_book_type] => Array ( [und] => Array ( [0] => Array ( [tid] => 1 ) ) ) [field_isbn] => Array ( ) [field_about_the_author] => Array ( [und] => Array ( [0] => Array ( [value] => Beachhed Don authoer............................ [format] => [safe_value] => Beachhed Don authoer............................ ) ) ) [rdf_mapping] => Array ( [rdftype] => Array ( [0] => sioc:Item [1] => foaf:Document ) [title] => Array ( [predicates] => Array ( [0] => dc:title ) ) [created] => Array ( [predicates] => Array ( [0] => dc:date [1] => dc:created ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] => Array ( [predicates] => Array ( [0] => dc:modified ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [body] => Array ( [predicates] => Array ( [0] => content:encoded ) ) [uid] => Array ( [predicates] => Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => Array ( [predicates] => Array ( [0] => foaf:name ) ) [comment_count] => Array ( [predicates] => Array ( [0] => sioc:num_replies ) [datatype] => xsd:integer ) [last_activity] => Array ( [predicates] => Array ( [0] => sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) ) [cid] => 0 [last_comment_timestamp] => 1357668665 [last_comment_name] => [last_comment_uid] => 1 [comment_count] => 0 [name] => admin [picture] => 0 [data] => b:0; [entity_view_prepared] => 1 )
I am trying to retrive the [value] of Description info ))))))))))))))))))))))))))))))))))))))0
I tried this
<?php
$node = menu_get_object(); //drupal code
if ( !empty($node) ) {
print $node ->body=>und=>0=>value;
}?>
and got an error about the '=' sign. What is the proper way to get my data?
[body] and [und] are arrays, so access them like this:
echo $node->body['und'][0]['value'];
It should be:
$node->body['und'][0]['value']
'Body' and 'und' are Arrays and need to be accessed with array syntax([]).
Accessing these values directly is sometimes frowned upon in drupal. You may want to look into: http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_render/7

UPS Shipping API Integration Error (PHP)

I download the ShippingGroundFreightWebService PHP examples from UPS.com. I got following error message:
SoapFault Object
(
[message:protected] => An exception has been raised as a result of client data.
[string:private] =>
[code:protected] => 0
[file:protected] => /home5/vizparts/public_html/PHP/SoapGroundFreightShipClient.php
[line:protected] => 193
[trace:private] => Array
(
[0] => Array
(
[file] => /home5/vizparts/public_html/PHP/SoapGroundFreightShipClient.php
[line] => 193
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => ProcessShipment
[1] => Array
(
[0] => Array
(
[Request] => Array
(
[RequestOption] => Array
(
[0] => 1
[1] => Shipping
)
)
[Shipment] => Array
(
[ShipFrom] => Array
(
[Name] => Pat Stewart
[TaxIdentification] => 1234567890
[Address] => Array
(
[AddressLine] => 2311 York Road
[City] => Timonium
[StateProvinceCode] => MD
[PostalCode] => 21093
[CountryCode] => US
)
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
[Extension] => 123
)
)
[ShipperNumber] => 222006
[ShipTo] => Array
(
[Name] => Superman
[Address] => Array
(
[AddressLine] => 2010 Warsaw Road
[StateProvinceCode] => GA
[PostalCode] => 30076
[CountryCode] => US
[City] => Roswell
)
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
[Extention] => 111
)
)
[PaymentInformation] => Array
(
[Payer] => Array
(
[Name] => Superman
[Address] => Array
(
[AddressLine] => 2010 Warsaw Road
[City] => Roswell
[StateProvinceCode] => GA
[PostalCode] => 30075
[CountryCode] => US
)
[ShipperNumber] => 00613270
[AttentionName] => String
[Phone] => Array
(
[Number] => 6785851000
)
)
[ShipmentBillingOption] => Array
(
[Code] => 10
[Description] => String
)
)
[Service] => Array
(
[Code] => 308
[Description] => String
)
[HandlingUnitOne] => Array
(
[Quantity] => 16
[Type] => Array
(
[Code] => PLT
[Description] => String
)
)
[Commodity] => Array
(
[CommodityID] => 22
[Description] => BUGS
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => String
)
[Value] => 511.25
)
[Dimensions] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => IN
[Description] => String
)
[Length] => 1.25
[Width] => 1.2
[Height] => 5
)
[NumberOfPieces] => 1
[PackagingType] => Array
(
[Code] => PLT
[Description] => String
)
[CommodityValue] => Array
(
[CurrencyCode] => USD
[MonetaryValue] => 265.2
)
[FreightClass] => 60
[NMFCCommodityCode] => 566
)
[Reference] => Array
(
[Number] => Array
(
[Code] => PM
[Value] => 1651651616
)
[BarCodeIndicator] => Array
(
[NumberOfCartons] => 5
[Weight] => Array
(
[UnitOfMeasurement] => Array
(
[Code] => LBS
[Description] => String
)
[Value] => 2
)
)
)
)
)
)
)
)
)
[faultstring] => An exception has been raised as a result of client data.
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
[detail] => stdClass Object
(
[Errors] => stdClass Object
(
[ErrorDetail] => stdClass Object
(
[Severity] => Hard
[PrimaryErrorCode] => stdClass Object
(
[Code] => 9121000
[Description] => Invalid Ship Request Document
)
)
)
)
)
I want to integrate the UPS API into my own website. I want to print the shipping label. How to fix this problem?
you should set the request xsd file,find it in other folder in the package you download.then set the request file with it.

Categories