Using Google Plus API to store stream data in MYSQL database - php

I've been playing with the Google+ API PHP starterkit. My ultimate goal is to run a cron job on my server that uses the Google+ API to grab the activity data, then store it in a MYSQL database-- where I can then dynamically update a twitter-like feed on a website.
Is this a possible/practical way of mining a Google+ profile's public stream? If not, what do you suggest as a good alternative?

Sounds like a good way to me.
One thing you have to keep in mind though is that there is no easy way to check if an activity has been deleted after you have added it to your database. You would have to check with $plus->activities->get($activityId) for each of the activities you want to display to see if it still exists (unless of course you don't mind them appearing on your website).
Apart from that your solution will work fine.

Related

Quickbooks PHP API Generating Invoices On Order Submission

I have a client that wants to take orders via an online form, with the idea being that an order can be submitted and stored in a database via my application while simultaneously generating an invoice on submission in QuickBooks.
How do I do this in PHP when the person entering in the order is not the client but a client of the client? It seems like Quickbooks uses Oauth tokens and a javascript library to generate them to connect a company to an app, but I'm simply writing a backend for one company and want that backend to create invoices when saving an order. How do I think about this?
I'm not interested in anyone having to hit a button that says "connect to quickbooks" especially not the person filling the order because again, that person is a customer and doesn't need to know about the internals of the customer's invoicing system.
I just really want to use the Accounting API to generate invoices. Is there no way to simply link my backend to my one company directly in the Quickbooks SDK configuration and achieve this, or do they need to use a javascript library to get tokens. I'm unclear about what direction I should be going in and don't want to waste time with a client-side library if I don't need it to do backend logic.
Here's some example code that does exactly what you're looking for:
https://github.com/consolibyte/quickbooks-php
Along with a quick-start guide:
http://www.consolibyte.com/docs/index.php/PHP_DevKit_for_QuickBooks_-_Intuit_Partner_Platform_Quick-Start
Also see notes about your comments below -- you're on the right track, you're just misunderstanding how OAuth works:
It seems like Quickbooks uses Oauth tokens and a javascript library to generate them to connect a company to an app, but I'm simply writing a backend for one company and want that backend to create invoices when saving an order.
Correct, Intuit uses OAuth, and a little Javascript thing to kick off the OAuth process.
I'm not interested in anyone having to hit a button that says "connect to quickbooks"
Someone needs to hit this button... BUT only ONE PERSON needs to hit the button ONCE, EVER, and then NEVER again.
The owner of the company (e.g. your boss) needs to click the button ONCE, which gives the OAuth creds (and the realm ID) to you. Once your boss has done this ONCE, then you have the creds to use forever, for all of the actual customers.
Your customers (e.g. the people actually checking out/placing orders) DO NOT click any buttons, nor do they see or have any idea at all that you're even using QuickBooks.
just really want to use the Accounting API to generate invoices.
Cool, you can totally do that!
Is there no way to simply link my backend to my one company directly in > the Quickbooks SDK configuration and achieve this, or do they need to use a javascript library to get tokens.
Follow the quick-start above. It should take you about 15 minutes to get a working OAuth connection, and then you never need to use the client-side stuff ever again.
You only need to authenticate every 180 days btw.
If you use the reconnect script, you only need to authenticate ONCE, and can automatically renew the tokens every 180 days, no user-interaction required.
https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/reconnect.php
Well with the realm_id for example, I don't understand how that relates to ouath.
The realm ID is just a unique identifier for the particular QuickBooks Online company you're trying to connect to. Yes, you need to store it. If you use our libs, this is done for you automatically.
I guess I don't understand if I'm developing for one client why can't I just get their realm_id from them and then keep using it rather than making them do some form of authentication?
Again, they only have to authenticate ONCE. That's Intuit's way of giving you the realm ID and credentials you need to connect. Once you've done it ONCE, you never need to do it again. It takes all of about 30 seconds.
If they were to just give you OAuth creds without any authentication, it would be a gigantic security hole. If you read the Wikipedia article on OAuth it talks in depth about this, and the goals of OAuth.
Okay I think I get it, so they have to authenticate once every 180 days?
Once every 180 days, UNLESS you use a reconnect script, in which case they just authenticate once and then never ever have to worry about it again.
So I can store the token and the realm_id in a database before it expires and just use that?
Yes.
In this way my client can authenticate and then my scripts can generate invoices for them when their customers visit our website?
Yes!

sending automatic push notification from mysql to android mobile

I have a database that contains some data and i want to get notified automatically on my mobile app if any value in the database is changed without having to check the database every certain time,i have tried many methods and viewed several tutorials but it leads me no where,any help ??
This is not going to be possible with only database. You need to write down an RESTful API which your app needs to poll to look for changes.
Ideal way of doing it is using GSM to push notify your app when ever you change something in your app. This will again require PHP/ASP/NodeJS etc... There must be some way you are updating your database? This should go exactly there.

How do I programatically search Google Plus for posts via the PHP library

I'm trying to get my head around how to use Google's PHP library to search Google Plus using the API. I want to create a command line script that can be run regularly (cron job) to search Google Plus for a key word and then store the results in a database. I will then have a website (moderation tool) that pulls the posts from the DB and allows the moderator to reply to the original poster (or not and delete's that post from the DB).
I can do this with curl on the public API but it feels dirty. I want to use their API properly with OAuth2 but that involves a website for authentication. I want to run it via a cron job php script at the command line.
Can this be done?
Keep in mind that, although you can use OAuth2 to authenticate against the Google+ API, you don't really get anything from doing so. The only thing you can get right now are public posts.
So what you're doing is fine. If you still want to use PHP for some reason, you can take a look at https://developers.google.com/+/api/latest/activities/search#examples and select "PHP" in the pull down to see some example PHP code. If you're having trouble with this, post a question with details about what you've tried and what problems you're having with it.

OpenFire Online/Offline Users in PHP

I have a OpenFire server running (it is using MySQL as it's database) and I'm trying to make a PHP http pre-bind system(using SASL) work with my web app.
I have got to a part of my app where I need to choose a random username that is not already online(for guest users). I was thinking of choosing some random users(in the Guests group I've created) and using the Presence Service plugin to check their online status until I find an available one(a user that's offline).
Is there a better way to get a list of offline/online users?
Does the server store the online status of users in the db?
I've been looking around the OpenFire db but I can't figure it out.
Thanks.
I wrote a small plugin for Openfire (with help of some other really simple plugin that I could plug without having to dig through the Openfire API docs) which basically spits out a JSON encoded list of users online. I could then just grab this and run json_decode and cycle through the array. I can't find the source at the moment, but it seems someone else made this aswell:
http://community.igniterealtime.org/thread/45107
EDIT:
I notice the Github project linked to in the above post is now gone, but I would try contacting them and see if they still have it.
ANOTHER EDIT:
Link to the Github repo: https://github.com/candy-chat/onlineUsersPlugin
In roster of the user, You can get online and offline users. Also you can get status message of online users from the roster.
But for that u have to subscribe the presence of that user. Only adding that user in roster is not enough you have to subscribe the presence of that user then you can get presence of other users.

Gears and Mysql sync

I am making an offline website that needs to sync every night with a server. Our employees work outside and sometimes underground and need to access the site for its database. But once home they must send us their findings.
The first time they connect, I check with google gears if they have the sqlite database and if not I run a script to insert it. Once they have it, I sync their next appointments to their local database.
When they are done, the next day, they connect to send us every thing and to download their new appointments.
For now i was able to create the sqllite database and insert new values inside thanks to google gears. But i haven t found a way to read the database with php to sync it with our online database.
To go from online to off, with PHP I can write an array in a hidden field and then read that field with JavaScript. But in the other way i was wondering if there was on other way then creating a form with DOM and submitting it in JavaScript to read the values with PHP?
I need to sync a Lot of values, do you know if there is an easier way?
Thanks for your help
I have found vortex, a powerfull script for gear that helps sync everything from files to data. It will definitely help me.
Here is the link to the developer's blog. The download link is in there.
I will come back when the website works to help the interested.
You should use Ajax for posting your new data to the PHP server.
You could use jquery (or any other framework), their lootle of resources how to post data to php on the web.
Your webpage could have a button hidden when offline, this button would enable user to start a synchronization.
Here a tutorial from PHP and jquery!

Categories