Hello folks I'm trying to access the created_on object using code below but it is not working, I'm getting incorrect date January 1, 1970 12:00. Also tried
$item = PodioItem::get($item_id);
$file_id = "";
$created_on = "";
foreach ($item->files as $file) {
echo date('F j, Y h:i',strtotime($file->created_on))."<br>";
}
Below is the response object from print_r($file,true), I can access the other object without any issue like $file->file_id, $file->link. What I'm trying to accomplish is store the created_on data in a variable then create a function to check and grab the latest date, then grab the file_id of it.
PodioFile Object
[__attributes:PodioObject:private] => Array
(
[file_id] => 464714088
[link] => https://files.podio.com/464714088
[perma_link] =>
[thumbnail_link] =>
[hosted_by] => podio
[name] => KEjj4UQSUV.PDF
[description] =>
[mimetype] => application/pdf
[size] => 785849
[created_on] => 2017-12-08 23:03:36
[rights] => Array
(
[0] => download
[1] => view
[2] => delete
[3] => update
)
PodioFile Object
(
[__attributes:PodioObject:private] => Array
(
[file_id] => 464716575
[link] => https://files.podio.com/464716575
[perma_link] =>
[thumbnail_link] =>
[hosted_by] => podio
[name] => IiaCfJjwws.PDF
[description] =>
[mimetype] => application/pdf
[size] => 785849
[created_on] => 2017-12-08 23:15:30
[rights] => Array
(
[0] => download
[1] => view
[2] => delete
[3] => update
)
PodioFile Object
(
[__attributes:PodioObject:private] => Array
(
[file_id] => 464728331
[link] => https://files.podio.com/464728331
[perma_link] =>
[thumbnail_link] =>
[hosted_by] => podio
[name] => g6cmAeUCiV.PDF
[description] =>
[mimetype] => application/pdf
[size] => 785849
[created_on] => 2017-12-08 23:49:15
[rights] => Array
(
[0] => download
[1] => view
[2] => delete
[3] => update
)
Luckily found the answer on sample provided here - https://hotexamples.com/examples/-/PodioItem/filter/php-podioitem-filter-method-examples.html
date_format($file->created_on, 'Y/m/d H:i:s') did the trick
Related
I'am tryng to get the value that an adress sent me on my adress, I have already setted up the webhook, but i can't understand a thing...
I have this array->
Array
(
[network] => tBTC
[event_type] => address-transactions
[addresses] => Array
(
[2MyXzRYSzrExLitY6FumGC3QgzCeqVoeQC1] => -49320
)
[data] => Array
(
[raw] =>
[hash] =>
[first_seen_at] => 2017-10-13T17:19:35+0000
[last_seen_at] => 2017-10-13T17:19:35+0000
[block_height] => 1210150
[block_time] => 2017-10-13T17:20:18+0000
[block_hash] =>
[confirmations] => 2
[is_coinbase] =>
[estimated_value] => 30000
[total_input_value] => 49320
[total_output_value] => 45510
[total_fee] => 3810
[estimated_change] => 15510
[estimated_change_address] => 2N7iSxafSoio4RE8wrd6outJNmbMkyP9QuL
[high_priority] =>
[enough_fee] =>
[contains_dust] =>
[inputs] => Array
(
[0] => Array
(
[index] => 0
[output_hash] =>
[output_index] => 0
[output_confirmed] => 1
[value] => 49320
[sequence] => 4294967295
[address] => 2MyXzRYSzrExLitY6FumGC3QgzCeqVoeQC1
[type] => scripthash
[multisig] =>
[multisig_addresses] =>
[script_signature] =>
)
)
[outputs] => Array
(
[0] => Array
(
[index] => 0
[value] => 30000
[address] => 2NBkQ8aTq8yeXdMWtxXNuxNgEHYnrzvcpV2
[type] => scripthash
[multisig] =>
[multisig_addresses] =>
[script] => OP_HASH160 OP_EQUAL
[script_hex] =>
[spent_hash] =>
[spent_index] => 0
)
[1] => Array
(
[index] => 1
[value] => 15510
[address] => 2N7iSxafSoio4RE8wrd6outJNmbMkyP9QuL
[type] => scripthash
[multisig] =>
[multisig_addresses] =>
[script] => OP_HASH160 OP_EQUAL
[script_hex] =>
[spent_hash] =>
[spent_index] => 0
)
)
[opt_in_rbf] =>
[unconfirmed_inputs] =>
[lock_time_timestamp] =>
[lock_time_block_height] =>
[size] => 367
)
[retry_count] => 0
And I'am tryng to get ONLY THE VALUE OF BTC (SATOSHI) THAT COME ON MY ADRESS, SO WITH THE SUBSTRACTION OF THE FEES, i thought that for get this values I had to get the
$Data=BlocktrailSDK::getWebhookPayload();
$Data['data']['estimated_value'];
Is this correct way to get at the 1000000% THE VALUE OF BTC (SATOSHI) THAT COME ON MY ADRESS, SO WITH THE SUBSTRACTION OF THE FEES, if is not what is the correct way??Anyway thanks for ready, hope that you all had a good day, and thanks for your time :)
P.S Note that on this transaction i sent 30000 satoshi+fees!
I need somehow to get the list of existing permissions in my Yii2 application.
yii/rbac/DbManager as authManager is used.
And when trying to run:
$permissions = Yii::$app->authManager->getPermissions();
I receive list in which are permissions and routes:
Array ( [/admin-tools/*] => yii\rbac\Permission Object ( [type] => 2 [name] => /admin-tools/* [description] => Access admin-tools [ruleName] => [data] => [createdAt] => 1500542371 [updatedAt] => 1500542371 ) [/admin/*] => yii\rbac\Permission Object ( [type] => 2 [name] => /admin/* [description] => access admin extension [ruleName] => [data] => [createdAt] => 1500541632 [updatedAt] => 1500541632 ) [/group] => yii\rbac\Permission Object ( [type] => 2 [name] => /group [description] => [ruleName] => [data] => [createdAt] => 1502190828 [updatedAt] => 1502190828 ) ) [permission_admin] => yii\rbac\Permission Object ( [type] => 2 [name] => permission_admin [description] => [ruleName] => [data] => [createdAt] => 1500559417 [updatedAt] => 1502190927 ) [permission_hr] => yii\rbac\Permission Object ( [type] => 2 [name] => permission_hr [description] => [ruleName] => [data] => [createdAt] => 1500559479 [updatedAt] => 1500559919 ) )
I suppose there is another smarter way to get this data. Because yii2-admin module is able to get list of only permissions, but I don`t have any idea how to do this?.
The resulting
$permissions = Yii::$app->authManager->getPermissions();
is an array with all the permissions object content
if you need only name and description you can iterate over the array eg:
$permissions = Yii::$app->authManager->getPermissions();
foreach($permissions as $key => $perm){
echo 'name : ' . $perm->name . ' description : ' . $perm->description . <br />;
echo
}
you can check yii2 doc http://www.yiiframework.com/doc-2.0/yii-rbac-dbmanager.html
http://www.yiiframework.com/doc-2.0/yii-rbac-basemanager.html#getPermissions()-detail
could b you are looking for getPermissionsByUser()
http://www.yiiframework.com/doc-2.0/yii-rbac-dbmanager.html#getPermissionsByUser()-detail
First off, I'm new to PHP and coding in general, so this might be quite an obvious answer.
I'm currently working with the Strava API, and I'm trying to extract data from an Array/Object which is the result of the following API call:
$recentactivities = $api->get('athlete/activities', array('per_page' => 100));
which returns:
Array (
[1] => stdClass Object (
[id] => XXXX
[resource_state] => 2
[external_id] => XXXX
[upload_id] => XXXX
[athlete] => stdClass Object (
[id] => XXXX
[resource_state] => 1
)
[name] => Let\'s see if I can remember how to do this cycling malarkey...
[distance] => 11858.3
[moving_time] => 1812
[elapsed_time] => 2220
[total_elevation_gain] => 44
[type] => Ride
[start_date] => 2014-07-12T13:48:17Z
[start_date_local] => 2014-07-12T14:48:17Z
[timezone] => (
GMT+00:00
) Europe/London
[start_latlng] => Array (
[0] => XXXX
[1] => XXXX
)
[end_latlng] => Array (
[0] => XXXX
[1] => -XXXX
)
[location_city] => XXXX
[location_state] => England
[location_country] => United Kingdom
[start_latitude] => XXXX
[start_longitude] => XXXXX
[achievement_count] => 4
[kudos_count] => 1
[comment_count] => 0
[athlete_count] => 1
[photo_count] => 0
[map] => stdClass Object (
[id] => a164894160
[summary_polyline] => XXXX
[resource_state] => 2
)
[trainer] =>
[commute] =>
[manual] =>
[private] =>
[flagged] =>
[gear_id] => b739244
[average_speed] => 6.544
[max_speed] => 10.8
[average_cadence] => 55.2
[average_temp] => 29
[average_watts] => 99.3
[kilojoules] => 179.9
[device_watts] =>
[average_heartrate] => 191.2
[max_heartrate] => 200
[truncated] =>
[has_kudoed] =>
)
This repeats for the most recent activities.
I'm attempting to extract average_heartrate, which I can do for a single object using the following:
$recentactivities[1]->average_heartrate;
but I'd like to extract all instances of average_heartrate from the Array. I've tried to use a foreach statement, but to be honest, I have no idea where to start.
Any help would be much appreciated.
It's actually pretty simple you can indeed use a foreach loop:
foreach($myArray as $obj){
//$obj is an object so:
if(isset($obj->average_heartrate)){
echo $obj->average_heartrate;
}
}
With this code you iterate through your array with objects and save the wanted array within an array so you can work further with it.
$heartrateArray = array(); // create a new array
//iterate through it with an foreach
foreach($recentactivities as $activity){
// save the average_heartrate as a value under a new key in the array
$heartrateArray[] = $activity->average_heartrate;
}
Here is my json response:
stdClass Object ( [is_claimed] => [rating] => 4 [mobile_url] => http://m.yelp.com/biz/the-waterboy-sacramento [rating_img_url] => http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png [review_count] => 455 [name] => The Waterboy [snippet_image_url] => http://s3-media1.ak.yelpcdn.com/photo/SZyFYvQmHWSLhK96SSzwwA/ms.jpg [rating_img_url_small] => http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png [url] => http://www.yelp.com/biz/the-waterboy-sacramento [menu_date_updated] => 1387494198 [reviews] => Array ( [0] => stdClass Object ( [rating] => 5 [excerpt] => AMAZING again, went here last Thursday at 5:00pm. Greeted by friendly man, he asked if we had a reservation, I said, 'no, do we need one?' He said, I'm... [time_created] => 1395158338 [rating_image_url] => http://s3-media1.ak.yelpcdn.com/assets/2/www/img/f1def11e4e79/ico/stars/v1/stars_5.png [rating_image_small_url] => http://s3-media1.ak.yelpcdn.com/assets/2/www/img/c7623205d5cd/ico/stars/v1/stars_small_5.png [user] => stdClass Object ( [image_url] => http://s3-media1.ak.yelpcdn.com/photo/SZyFYvQmHWSLhK96SSzwwA/ms.jpg [id] => H0qUqWctz5Ms6qdeaIvjFw [name] => Lori T. ) [rating_image_large_url] => http://s3-media3.ak.yelpcdn.com/assets/2/www/img/22affc4e6c38/ico/stars/v1/stars_large_5.png [id] => bZznirkpADmW3Qcpc5u_VA ) ) [phone] => 9164989891 [snippet_text] => AMAZING again, went here last Thursday at 5:00pm. Greeted by friendly man, he asked if we had a reservation, I said, 'no, do we need one?' He said, I'm... [image_url] => http://s3-media1.ak.yelpcdn.com/bphoto/9e5sodvvP3p6_53wOqVTcg/ms.jpg [categories] => Array ( [0] => Array ( [0] => French [1] => french ) [1] => Array ( [0] => Italian [1] => italian ) ) [display_phone] => +1-916-498-9891 [rating_img_url_large] => http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png [menu_provider] => single_platform [id] => the-waterboy-sacramento [is_closed] => [location] => stdClass Object ( [city] => Sacramento [display_address] => Array ( [0] => 2000 Capitol Ave [1] => Midtown [2] => Sacramento, CA 95811 ) [neighborhoods] => Array ( [0] => Midtown ) [postal_code] => 95811 [country_code] => US [address] => Array ( [0] => 2000 Capitol Ave ) [state_code] => CA ) )
which I get using:
$response = json_decode($data);
print_r($response);
echo $response["rating"]; //Why this does not give json response value?
Pass true into the second parameter of json_decode to return an array (which is how you're trying to access it):
$response = json_decode($data, true); // associative array returned
print_r($response);
echo $response["rating"]; // 4
Manual
Otherwise, access the rating as a property of the object that you've got:
$response = json_decode($data);
echo $response->rating; // 4
I'm trying to use the stackoverflow API and I want to get answers of a question in a php array. So far here is my php code:
<?php
//KEY
$string = "key=my_key";
//Call stack API .$string
$stack_url = "compress.zlib://http://api.stackoverflow.com/1.1/questions";
//Get and Store API results into a variable
$result = file_get_contents($stack_url);
$jsonArray = json_decode($result);
print_r($jsonArray);
//echo($jsonArray->questions[0]->question_answers_url);
//var_dump($jsonArray);
?>
I want to store the answers of a question in an array called answers so that I can access them with a for loop.
The answer i get is :
stdClass Object
(
[total] => 2618591
[page] => 1
[pagesize] => 30
[questions] => Array
(
[0] => stdClass Object
(
[tags] => Array
(
[0] => c#
[1] => ssh
[2] => openssh
[3] => rsacryptoserviceprovider
)
[answer_count] => 1
[favorite_count] => 0
[question_timeline_url] => /questions/9164203/timeline
[question_comments_url] => /questions/9164203/comments
[question_answers_url] => /questions/9164203/answers
[question_id] => 9164203
[owner] => stdClass Object
(
[user_id] => 311966
[user_type] => registered
[display_name] => simonc
[reputation] => 301
[email_hash] => 021f3344004f0c886d715314fa02037d
)
[creation_date] => 1328548627
[last_edit_date] => 1328611688
[last_activity_date] => 1328611688
[up_vote_count] => 0
[down_vote_count] => 0
[view_count] => 25
[score] => 0
[community_owned] =>
[title] => Format of PKCS private keys
)
[1] => stdClass Object
(
[tags] => Array
(
[0] => c#
[1] => .net
[2] => combobox
)
[answer_count] => 3
[favorite_count] => 0
[question_timeline_url] => /questions/9174765/timeline
[question_comments_url] => /questions/9174765/comments
[question_answers_url] => /questions/9174765/answers
[question_id] => 9174765
[owner] => stdClass Object
(
[user_id] => 1194399
[user_type] => registered
[display_name] => Goxy
[reputation] => 1
[email_hash] => 5fc8c96b6b85c6339cb9ac4ab60cb247
)
[creation_date] => 1328611202
[last_activity_date] => 1328611686
[up_vote_count] => 0
[down_vote_count] => 0
[view_count] => 15
[score] => 0
[community_owned] =>
[title] => WPF: Bind simple List<myClass> to Combobox
)
....
Not sure exactly which property you want to extract, but I assume it's the 'question_answers_url'.
$answersArray = Array();
for($i=0;$i<count($jsonArray['questions']);$i++){
//assuming it is the 'question_answers_url' property that you want
array_push($answersArray,$jsonArray['questions'][$i]['question_answers_url']);
}
Ought to do it.