Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP to pass all msg details to Python script? #1

Open
DJF3 opened this issue Jan 13, 2016 · 2 comments
Open

PHP to pass all msg details to Python script? #1

DJF3 opened this issue Jan 13, 2016 · 2 comments

Comments

@DJF3
Copy link

DJF3 commented Jan 13, 2016

(not really an issue, more a question for understanding)
Hi,
First of all, many thanks for sharing this. When looking at the code I was wondering something:

  • In Ciscospark.php you get all the message details but only pass on the message ID to
  • the sparkmess.py script, where you access spark to pull in the same details

Would it make sense to pass on all details coming in through the Webhook and pass these to sparkmess.py so this doesn't have to go out to Spark and get it again?

Cheers
DJ

@brbester
Copy link
Owner

Thank you for the feedback and taking a look. I am hoping this will help others start playing with the API.

Short answer is I needed to grab the message details to get the message text due to Spark's secure implementation (For reference: https://developer.ciscospark.com/webhooks-explained.html). When I grab the message details I am getting the roomid so no need to pass. On my first version I actually did pass the roomid as well. I may need to update these examples, FYI, ran into a couple of issues:

  1. If you pull your AT from a file, make sure to rstrip() to eleiminate a trailing "/n" or Spark may through a JSON parse error

  2. If a room contains attachments without text, python will through an error because it sees dictionary entries without a 'text' key. So you need to check if the key exists before printing, assigning a variable to it, etc...

Also let me know if there are any methods you want me to add - I threw in a quick find roomid by room name and suspect there may be similar common actions it would help to have in the library directly.

-Brad

@brbester brbester reopened this Jan 13, 2016
@DJF3
Copy link
Author

DJF3 commented Jan 20, 2016

..."I am hoping this will help others start playing with the API."...
Yes you did... Using this code I wrote a "bot" that connects to my house (security camera's, power usage, water usage, etc.etc.)

Thank you Brad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@brbester @DJF3 and others