Yammer: get usernames with messages - yammer

I was wondering how I could get the usernames, etc. from messages using the API. Calling the GET messages API gives me all the info I need from the message, but I only get the userID. Because of API request limits, I can't afford to do another API request to know for each messages all the needed userinfo.
Am I missing something, or is this simply not possible?

In fact, check the "references" part of the response and you will find the whole details concerning your user.

I dont see where that is? This is my API response from yammer (for one message)
Array
(
[0] => stdClass Object
(
[id] => 544689850
[sender_id] => 1507082247
[replied_to_id] => 544673530
[created_at] => 2015/06/04 13:03:09 +0000
[network_id] => 355014
[message_type] => update
[sender_type] => user
[url] => https://www.yammer.com/api/v1/messages/544689850
[web_url] => https://www.yammer.com/b-rail.be/messages/544689850
[group_id] => 5741341
[body] => stdClass Object
(
[parsed] => Signed and Approved!
[plain] => Signed and Approved!
[rich] => Signed and Approved!
)
[thread_id] => 544673530
[client_type] => Web
[client_url] => https://www.yammer.com/
[system_message] =>
[direct_message] =>
[chat_client_sequence] =>
[language] => en
[notified_user_ids] => Array
(
)
[privacy] => private
[attachments] => Array
(
)
[liked_by] => stdClass Object
(
[count] => 0
[names] => Array
(
)
)
[content_excerpt] => Signed and Approved!
[group_created_id] => 5741341
)

Related

How do i know notification send to firebase or not

i want to send notification to specific android device with laravel-firebase . currently i am following this "brozot/laravel-fcm" so when Sending a Downstream Message to a Device , how do i know notification is send or not . when i test it in my postman it returns
LaravelFCM\Response\DownstreamResponse Object
(
[numberTokensSuccess:protected] => 0
[numberTokensFailure:protected] => 1
[numberTokenModify:protected] => 0
[messageId:protected] =>
[tokensToDelete:protected] => Array
(
[0] => .....
)
[tokensToModify:protected] => Array
(
)
[tokensToRetry:protected] => Array
(
)
[tokensWithError:protected] => Array
(
)
[hasMissingToken:protected] =>
[tokens:LaravelFCM\Response\DownstreamResponse:private] => Array
(
[0] => .....
)
[logEnabled:protected] =>
)
You can see in the response how many messages succeeded or failed. From your own output above:
[numberTokensSuccess:protected] => 0
[numberTokensFailure:protected] => 1
It looks like you tried to send a message to one device, and it failed.

Square API - Object Update for Multiple Locations

I'm trying to update objects using the endpoint BatchRetrieveCatalogObjects (POST /v2/catalog/batch-upsert).
When I post the request, I get the error
[type] => bad_request
[message] => Multi-location support is unavailable for this endpoint. Parameter `merchant_id` must correspond to a single-location account, not a business account
How can I update objects if there are multiple locations and if items have location overrides?
Is there another endpoint that I can use?
UpsertCatalogObject (POST /v2/catalog/object) does not work either. Same error.
Below is a sample request payload:
Array
(
[idempotency_key] => 1122334455667788
[batches] => Array
(
[type] => ITEM
[id] => 5BLFIPNYBTDD5ARZYQU4K7SV
[item_data] => Array
(
[name] => Honey Mead
[description] => Mead is an adult beverage brewed exclusively with honey.
[category_id] => OIMGQF7DCO7W6SEXEMKGIJK5
)
[variations] => Array
(
[type] => ITEM_VARIATION
[id] => BEQZ6FXAJACGW55RRZBMXDEI
[item_variation_data] => Array
(
[item_id] => 5BLFIPNYBTDD5ARZYQU4K7SV
[name] => Case (24 bottles)
[pricing_type] => FIXED_PRICING
[ordinal] => 4
[price_money] => Array
(
[amount] => 11900
)
[location_overrides] => Array
(
[0] => Array
(
[location_id] => 81J6E4K21KGC9
[price_money] => Array
(
[amount] => 11900
)
[pricing_type] => FIXED_PRICING
[track_inventory] => 1
[inventory_alert_type] => LOW_QUANTITY
[inventory_alert_threshold] => 15
)
)
)
)
)
)
Additional Notes for Clarification:
I'm trying to edit the price at either the variation or location_overrides level. I get the error for any call to the endpoint. I think the Square API developers don't allow any calls to the endpoint for any multi-unit locations. I also cannot delete locations either on the website or API. They only allow you to hide locations, which I did. But the error still persists.
I tried the v1 endpoint and get strange results. V1 & V2 use different variation_id. So if I pass a v2 variation_id to the v1 endpoint, it creates a new variation rather than updating it. The new variation then displays a new field called catalog_v1_id. Then when I try to delete the variation on the website, it disappears from the website view but still exists as an active item when I call the v2 list variation endpoint. I'm thinking this API has a whole host of bugs and is not ready for prime time.

How can I sort an array by specific value containing class object inside it?

I want to sort this array by product price in ascending order. How can I do this?
Array
(
[0] => stdClass Object
(
[product_id] => 16
[product_name] => Ferrari 4802
[product_details] => I know this car is good. Because I have driven this car 10 year.
[product_quantity] => 1
[product_price] => 2560
[shipping_cost] => 1000
[product_image] => ./admin_assets/image/uploads/product_image/ea28444f93d1fea413c95861bf306fbf.jpg
[product_details_image] => ./admin_assets/image/uploads/product_details/ea28444f93d1fea413c95861bf306fbf.jpg
[thumbnails_image] => ./admin_assets/image/uploads/thumbnails/ea28444f93d1fea413c95861bf306fbf.jpg
[slidder_image] => ./admin_assets/image/uploads/slidders/ea28444f93d1fea413c95861bf306fbf.jpg
[status] => 1
[slidder] =>
[category_id] => 4
)
[1] => stdClass Object
(
[product_id] => 15
[product_name] => Laborghini urus
[product_details] => I know this car is good. Because I have driven this car 10 year.
[product_quantity] => 2
[product_price] => 500
[shipping_cost] => 1000
[product_image] => ./admin_assets/image/uploads/product_image/68a7eb1c6bf5b3b43f0c3fd4ed143c68.jpg
[product_details_image] => ./admin_assets/image/uploads/product_details/68a7eb1c6bf5b3b43f0c3fd4ed143c68.jpg
[thumbnails_image] => ./admin_assets/image/uploads/thumbnails/68a7eb1c6bf5b3b43f0c3fd4ed143c68.jpg
[slidder_image] => ./admin_assets/image/uploads/slidders/68a7eb1c6bf5b3b43f0c3fd4ed143c68.jpg
[status] => 1
[slidder] =>
[category_id] => 4
)
[2] => stdClass Object
(
[product_id] => 14
[product_name] => Laborghini hurican023
[product_details] => I know this car is good. Because I have driven this car 10 year.
[product_quantity] => 4
[product_price] => 50
[shipping_cost] => 1000
[product_image] => ./admin_assets/image/uploads/product_image/65e660ef6e3ebcb0773d87c048c93e1b.png
[product_details_image] => ./admin_assets/image/uploads/product_details/65e660ef6e3ebcb0773d87c048c93e1b.png
[thumbnails_image] => ./admin_assets/image/uploads/thumbnails/65e660ef6e3ebcb0773d87c048c93e1b.png
[slidder_image] => ./admin_assets/image/uploads/slidders/65e660ef6e3ebcb0773d87c048c93e1b.png
[status] => 1
[slidder] =>
[category_id] => 4
)
)
Because the array is generated by a database query you can easily have the query do the sorting for you.
You don't show your model code but assuming you are using Query Builder (a.k.a. Active Record) you need the following in your model before you execute $this->db->get().
$this->db->order_by('product_price', 'ASC');
Here is some example code showing a full query. It assumes the table is named 'products', you want to select all the table's fields, and you want only a particular 'category_id'.
In the Model file:
public function product_by_category($category)
{
$query = $this->db
->where('category_id', $category)
->order_by('product_price', 'ASC')
->get('products');
//return all records or NULL if no records are found
return $query->num_rows() > 0 ? $query->result() : NULL;
}

Magento custom shippment method

I wrote shippment module with checking a lot of resources/tutorials etc. I am using magento 1.9. Source of module is:
https://github.com/aleextra/magentoshipping
I lost full day to find why it doesn't works fine. Magento see my module, when I am adding at Model/Carrier.php at line 52 code:
die($result);
it shows objec dump:
Mage_Shipping_Model_Rate_Result Object
(
[_rates:protected] => Array
(
[0] => Mage_Shipping_Model_Rate_Result_Method Object
(
[_data:protected] => Array
(
[carrier] => mikshipping
[carrier_title] => Mik Carrier
[method] => fixed
[method_title] => Fixed price 10
[price] => 10
[cost] => 10.00
)
[_hasDataChanges:protected] => 1
[_origData:protected] =>
[_idFieldName:protected] =>
[_isDeleted:protected] =>
[_oldFieldsMap:protected] => Array
(
)
[_syncFieldsMap:protected] => Array
(
)
)
)
[_error:protected] =>
)
What I am doing wrong?
As a quick guess I say that your carriers name in the config.xml (mshipping) does not match the code used in Carrier.php (mikshipping). I have them always being the same so Iḿ not absolutely sure if this might cause the issue, but it is easy to check.

Zend Framework Validate field is integer between 1 and 5

I use Zend\InputFilter\InputFilter class for form validation. point field should accept only integers between 1 and 5. But it doesn't work properly it accepts string starting with integers between 1 and 5. For example 1kjhkjh, 2tgfjhgfjhf, 4jhkljg...
What is wrong in my code?
$inputFilter->add (
$inputFilter->getFactory()->createInput (
array (
'name' => 'point',
'required' => true,
'validators' => array (
array(
'name' => 'Digits'),
array (
'name' => 'Between',
'options' => array (
'min' => 1,
'max' => 5,
'messages' => array('notBetween' => 'Point must be between %min% and %max%')
)
)
)
)
)
);
Use the the second parameter of zend validator to break the validators chain and return an error, breakChainOnFailure (documentation) tells the element to stop validating if this error is triggered, so in your case if it is not a digit the user gets an error, when the user has fixed the error the second validator will get triggered too:
$inputFilter->add (
$inputFilter->getFactory()->createInput (
array (
'name' => 'point',
'required' => true,
'validators' => array (
array(
'name' => 'Digits', 'breakChainOnFailure' => true),
array (
'name' => 'Between',
'options' => array (
'min' => 1,
'max' => 5,
'messages' => array('notBetween' => 'Point must be between %min% and %max%')
)
)
)
)
)
);
Another option would be to replace Zend_Validate_Digits with Zend_Validate_Int (docmentation) depending of what error message you prefer to give to the user if he enters non valid data. Of course as suggested in the comments you could also use the Zend_Filter_Int if what you want is to handle any non valid data by fixing it yourself and do not give the user feedback about what he did wrong.
'breakChainOnFailure': true
should be
'breakChainOnFailure'=> true

Resources