Set reminder to a task API Podio - php

I try to set a reminder (30 minutes before due date) on a task created by the API based on doc examples: https://developers.podio.com/doc/tasks/create-task-with-reference-22420
https://developers.podio.com/doc/tasks/create-task-22419
Here's the code:
PodioTask::create_for(
'item',
$order->item_id,
array(
'text' => "Préparer la livraison de la commande",
'description' => "Testing tasks",
'responsible' => 00000,
'due_date' => date('Y-m-d'),
'due_time' => '09:00:00',
'reminder' => array('remind_delta' => 30)
)
);
Beside of the fact that the reminder is not set, the task is created with the provided information above. There is no error related to the API.
Is there something missing?

I realize this is old, but I finally figured it out. See below:
PodioTask::create_for(
'item',
$item_id,
$attributes = array (
'text' => $item_id,
'private' => true,
'due_date' => $appt_date,
'due_time' => $appt_time,
'responsible' => 1234567, // User ID
'reminder' => (object)[
'remind_delta' => 0
]
)
);
For my purposes the user will always be the same, so I set that as static.
BE AWARE You MUST authenticate with the API using the users credentials that the reminder is being set for. It WILL NOT set a reminder for another user (partially why I'm using a static user).
EDIT Since I don't have enough reputation points, I want to call out Pavlo - Podio
One can verify if a reminder is set by looking at it in Podio. It's pretty simple, either there's a reminder set or there's not.
The OP, and myself, aren't using Ruby, so whether Ruby works or not is irrelevant to the problems we're facing.
While I realize you were trying to help. The fact that you're a "Test Automation Engineer at Podio" raises the expectation that you COULD provide useful information. So pull out the PHP and see what we're experiencing.

Related

How to create a new source and set as default source on Stripe API

I'm looking for a way to create a new source for a customer and then set that source as the default source for the customer. The problem I'm currently facing is that the response from creating the source does not give me a easy way to identify the id for the new created source so that I can set that source as default.
Below is my code, without any API key and customer ID:
\Stripe\Stripe::setApiKey($stripe_api_key);
$customer = \Stripe\Customer::retrieve($_SESSION['parent']['stripe_customer_id']);
$customer->sources->create(array('source' => array("object" => "card", 'exp_month' => $expire_month, 'exp_year' => $expire_year, 'number' => $card_number, 'address_line1' => $billing_address1, 'address_line2' => $billing_address2, 'address_city' => $billing_city, 'address_zip' => $billing_postal_code, 'address_country' => $billing_country, 'currency' => 'GBP', 'cvc' => $security_code, 'name' => $_SESSION['parent']['firstname'] . ' ' . $_SESSION['parent']['lastname'])))->__toArray(true);
//set as default
if (isset($_POST['check_default_source'])) {
$customer->default_source=$customer['id'];
$customer->save();
}
I also had this problem, slightly different.
I added a new source from a token_id.
The getLastResponse method was not available in my API or library version.
But using the token object (Stripe::Token::retreive( token_id )) you can actually retrieve the card_id, and use that to update the default_source.
Took me a long time to figure this out, so I post it here. Maybe it helps someone in the future...
I was able to to find the solution to my question. Stripe API does send back the id of the source that was just created and to get the ID I use the below code:
$source_id = json_decode($customer->sources->getLastResponse()->body)->id;

'SenderID' issues sending SMS on Amazon SNS (Official PHP SDK)

For some reason the SenderID seems to revert to NOTICE - see here when I set the SenderID in the code.
When I leave the SenderID variable out, it sends as the default set - this is good, but we will be occasionally changing the name for different uses.
I am using the Official PHP SDK, with the code below:
$aws_cred = array(
'credentials' => array(
'key' => 'GOT THE KEY',
'secret' => 'GOT THE SECRET',
),
'region' => 'eu-west-1', // < your aws from SNS Topic region
'version' => 'latest'
);
$sns = new \Aws\Sns\SnsClient($aws_cred);
$args = array(
"SenderID" => "MySendID",
"SMSType" => "Promotional",
"Message" => "Amazon y u do dis??",
"PhoneNumber" => "+number"
);
$result = $sns->publish($args);
I am sending to the UK (so SID works there), and also it is within the 11 character limit.
Does anyone have any idea why this is happening?
Cheers
I have found the answer.
The search system didn't materialise this originally, but finally, I have found it.
QUOTE FROM: https://stackoverflow.com/a/43748448/7586984
I found the solution. Set the args this way. It works!
$args = array(
'MessageAttributes' => [
'AWS.SNS.SMS.SenderID' => [
'DataType' => 'String',
'StringValue' => 'YourSenderName'
]
],
"SMSType" => "Transactional",
"PhoneNumber" => "+87654321",
"Message" => "Hello World!"
);
(Optional) For Sender ID, type a custom ID that contains up to 11
alphanumeric characters, including at least one letter and no spaces.
The sender ID is displayed as the message sender on the receiving
device. For example, you can use your business brand to make the
message source easier to recognize.
Support for sender IDs varies by country. For example, messages
delivered to U.S. phone numbers will not display the sender ID. For
the countries that support sender IDs, see Supported Regions and
Countries.
If you do not specify a sender ID, the message will display a long
code as the sender ID in supported countries. For countries that
require an alphabetic sender ID, the message displays NOTICE as the
sender ID.
http://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html
to sumerise you cant use spaces(you have one) and it wont always work, it depends on country and carrier, it wont work in more places than it will

Pusher/Wrench on Ubuntu 12.04 with PHP

A site I am currently grabbing a lot of data from via API recently implemented Pusher to provide real-time updates. They then link to the page http://pusher.com/docs/client_libraries for client side libraries in several languages.
So the PHP client library linked to at http://pusher.com/docs/client_libraries appears to be bad.
First, the Git repo (via browser) doesn't download everything but once you get that figured out it still doesn't work. The basic flow is connect to Psher server with App key, then subscribe to one or more channels, then listen forever to those channels for updates.
The connect appears to work. The subscribe appears to work. The top level object from the PHP library leads to a recursion error (too deep) when I use var_export on it. Here's the resulting object after I subscribe to a channel:
Wrench\Payload\HybiPayload::__set_state(array( 'frames' => array ( 0 => Wrench\Frame\HybiFrame::__set_state(array( 'masked' => false, 'mask' => NULL, 'offset_payload' => 2, 'offset_mask' => 2, 'length' => 84, 'type' => NULL, 'buffer' => 'T{"event":"pusher:connection_established","data":"{\\"socket_id\\":\\"34937.7965561\\"}"}', 'payload' => '', )), ), ))
From there it waits for an update from the channel and when an update occurs I get the following:
Wrench\Payload\HybiPayload::__set_state(array( 'frames' => array ( 0 => Wrench\Frame\HybiFrame::__set_state(array( 'masked' => false, 'mask' => NULL, 'offset_payload' => 4, 'offset_mask' => 4, 'length' => 153, 'type' => NULL, 'buffer' => '~' . "\0" . '™{"event":"pusher:error","data":{"code":null,"message":"Pusher protocol versions <= 3 have been deprecated. Support will be removed after November 2013"}}', 'payload' => '', )), ), ))
and
array ( 0 => WrenchPusher\PusherMessage::__set_state(array( 'event' => 'pusher:connection_established', 'channel' => NULL, 'data' => stdClass::__set_state(array( 'socket_id' => '34937.7965561', )), )), 1
=> WrenchPusher\PusherMessage::__set_state(array( 'event' => 'connection_established', 'channel' => NULL, 'data' => stdClass::__set_state(array( 'socket_id' => '34937.7965561', )), )), 2
=> WrenchPusher\PusherMessage::__set_state(array( 'event' => 'pusher:error', 'channel' => NULL, 'data' => stdClass::__set_state(array( 'code' => NULL, 'message' => 'Pusher protocol versions <= 3 have been deprecated. Support will be removed after November 2013', )), )),
Now the obvious issue would be the part about version 3 not being supported. The script fails on a json_decode call which is expecting a string but is getting an object.
Despite several Google searches on the matter I have not been able to find an updated library.
Has anyone worked with a more up-to-date Pusher/Wrench PHP library? Any recommendations are welcome.
Thanks
Update 04/11/14:
Pusher support was kind enough to take 2 days to confirm that the library is in fact broken. And to tell me that they won't do anything about it. So if you want Pusher client in PHP you appear to be out of luck for now.
I also know Ruby and checked into that library. It also looked old but I didn't spend a lot of time looking into the details. After wasting my time on the broken PHP library I assumed the Ruby one was probably broken as well. Pusher seems to prefer javascript.

MongoDB - PHP manual references approach suitability

MongoDB newbie here. I'm having the first approach on references, and my main doubt is if i'am using the appropriate strategy(manual references) for my situation.
Working on 2 collections(user, message) in the same db, lets make an example of a document stored in user collection:
array (
'_id' => new MongoId("5231817277758e660c7202c4"),
'uname' => 'pluto',
'pwd' => new MongoInt32(1234567),
'email' => 'pluto1#gmail.com',
'phone_home' => new MongoInt64(23409238),
'phone_work' => new MongoInt64(54389724),
'phone_mobile' => new MongoInt64(9823422),
'visible' => new MongoInt32(1),
)
and an example of a document stored in message collection (sent FROM an other user TO the user above 'pluto'):
array (
'_id' => new MongoId("524358102660b2c70b8b4567"),
'from_uid' => '5231817277758e660c7202d7',
'to_uid' => '5231817277758e660c7202c4',
'object' => 'mongo manual Ref',
'content' => 'is that the correct approach?',
'datetime' => '2013-09-25 23:39:28',
)
The user logged in ('pluto') can see all the messages he received from other users but, i don't wat to print the 'from_uid' value, i want to replace it with the username of the sender.
My main doubt is if manual references is the right approach for this scenario, because with this technique(if i havn't miss understood everything), print a list of message would involve:
the 'query' for print the list of messages
an other 'query' for retrieve the username from the other collection, for each messages. Also if a user have received 1000 messages, this approach will have to run 1001 query??
My secondary doubt is if there is a way for directly merge or replace the result of two cursors
Given your use case it would probably be ok to duplicate a little bit of data and store some of the necessary fields about the sending user as an embedded document - in this case, the username.
array (
'_id' => new MongoId("524358102660b2c70b8b4567"),
'from_user' => array(
'uid' => '5231817277758e660c7202d7',
'uname' => 'mars'
),
'to_uid' => '5231817277758e660c7202c4',
'object' => 'mongo manual Ref',
'content' => 'is that the correct approach?',
'datetime' => '2013-09-25 23:39:28',
)
This approach means that when you query for messages to a user ( in which you already know the to_uid), you get all of the messages with the correct id to the from_user, but also already have their username to display.
Now, instead of querying 1000+ times, you only need to query when there is more information needed about a user - such as fetching their profile, etc...

understanding ElasticSearch routing

I am trying to use the elasticsearch routing mapping to speed up some queries, but I am not getting the expected result set (not worried about the query performance just yet)
I am using Elastic to set up my mapping:
$index->create(array('number_of_shards' => 4,
'number_of_replicas' => 1,
'mappings'=>array("country"=>array("_routing"=>array("path"=>"countrycode"))),
'analysis' => array(
'analyzer' => array(
'indexAnalyzer' => array(
'type' => 'keyword',
'tokenizer' => 'nGram',
'filter' => array('shingle')
),
'searchAnalyzer' => array(
'type' => 'keyword',
'tokenizer' => 'nGram',
'filter' => array('shingle')
)
)
) ), true);
If I understand correctly, what should happen is that each result should now have a field called "countrycode" with the value of "country" in it.
The results of _mapping look like this:
{"postcode":
{"postcode":
{"properties":
{
"area1":{"type":"string"},
"area2":{"type":"string"},
"city":{"type":"string",
"include_in_all":true},
"country":{"type":"string"},
"country_iso":{"type":"string"},
"country_name":{"type":"string"},
"id":{"type":"string"},
"lat":{"type":"string"},
"lng":{"type":"string"},
"location":{"type":"geo_point"},
"region1":{"type":"string"},
"region2":{"type":"string"},
"region3":{"type":"string"},
"region4":{"type":"string"},
"state_abr":{"type":"string"},
"zip":{"type":"string","include_in_all":true}}},
"country":{
"_routing":{"path":"countrycode"},
"properties":{}
}
}
}
Once all the data is in the index if I run this command:
http://localhost:9200/postcode/_search?pretty=true&q=country:au
it responds with 15740 total items
what I was expecting is that if I run the query like this:
http://localhost:9200/postcode/_search?routing=au&pretty=true
Then I was expecting it to respond with 15740 results
instead it returns 120617 results, which includes results where country is != au
I did note that the number of shards in the results went from 4 to 1, so something is working.
I was expecting that in the result set there would be an item called "countrycode" (from the rounting mapping) which there isn't
So I thought at this point that my understand of routing was wrong. Perhaps all the routing does is tell it which shard to look in but not what to look for? in other words if other country codes happen to also land in that particular shard, the way those queries are written will just bring back all records in that shard?
So I tried the query again, this time adding some info to it.
http://localhost:9200/postcode/_search?routing=AU&pretty=true&q=country:AU
I thought by doing this it would force the query into giving me just the AU place names, but this time it gave me only 3936 results
So I Am not quite sure what I have done wrong, the examples I have read show the queries changing from needing a filter, to just using match_all{} which I would have thought would only being back ones matching the au country code.
Thanks for your help in getting this to work correctly.
Almost have this working, it now gives me the correct number of results in a single shard, however the create index is not working quite right, it ignores my number_of_shards setting, and possibly other ones too
$index = $client->getIndex($indexname);
$index->create(array('mappings'=>array("$indexname"=>array("_routing"=>array("required"=>true))),'number_of_shards' => 6,
'number_of_replicas' => 1,
'analysis' => array(
'analyzer' => array(
'indexAnalyzer' => array(
'type' => 'keyword',
'tokenizer' => 'nGram',
'filter' => array('shingle')
),
'searchAnalyzer' => array(
'type' => 'keyword',
'tokenizer' => 'nGram',
'filter' => array('shingle')
)
)
) ), true);
I can at least help you with more info on where to look:
http://localhost:9200/postcode/_search?routing=au&pretty=true
That query does indeed translate into "give me all documents on the shard where documents for country:AU should be sent."
Routing is just that, routing ... it doesn't filter your results for you.
Also i noticed you're mixing your "au"s and your "AU"s .. that might mix things up too.
You should try setting required on your routing element to true, to make sure that your documents are actually stored with routing information when being indexed.
Actually to make sure your documents are indexed with proper routing explicitly set the route to lowercase(countrycode) when indexing documents. See if that helps any.
For more information try reading this blog post:
http://www.elasticsearch.org/blog/customizing-your-document-routing/
Hope this helps :)

Categories