OpenFire Online/Offline Users in PHP - 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.

Related

Youtube [Data-API] LiveChat where logged-in user is moderator

I'm trying to work out how i get a list of videos/streams where the user is a moderator for live chat.
This is done in nightbot and fussbot but i can't work out how they do it, it works by you adding the Nightbot channel as a moderator of your live streams chat but im unsure how they get your live stream to watch the chat from them being added as a moderator to the channel. (i'm guessing they are a channel moderator and not a video/stream as they are persistent though all casts)
I have thought it would be in the API docs but if it is i can't find it / not sure what im looking for.
I'm implementing this in PHP and so far i have it now getting stream events id's and your persistent live stream ids but i'm now stuck.
I don't think the API supports a way to retrieve a list of chats where the logged-in user is a moderator. The liveChatModerators.list method requires that a value be set for the liveChatId parameter, and that value must specify a single live chat ID.
I'll caveat the following by saying that I'm not familiar with the apps you mentioned or how they work, so this is just conjecture. Your question describes a third-party app that lets you (or helps you to) manage YouTube live chats. Presumably, to use the app, you must have granted that app permission to manage your YouTube account.
With that in mind, if you set up a live stream through that app, then the app could, while creating the live stream, also use the liveChatModerators.insert method to add its own channel as a moderator to the live stream's chat. Similarly, the app could retrieve your list of live streams and add its own channel as a moderator to any of those live streams. The app could use its own data store to determine whether its channel had already been added as a moderator for any particular chat.
Please post a comment in reply if you don't think I'm understanding your question.

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!

Sign in with fb or twitter

For a project I am working on, I think having the functionality to sign in with facebook/ twitter would be beneficial.
I have some design theory to iron out.
When the user first logs into the website using either twitter or facebook, I'll get their email and other relevant information and store it in the database where a normal signed up user would be stored.
When they return, they would log in with twitter/ fb again and it would locate the information in the database and not add it again.
If anyone tried to sign up with the email address provided by either of these services, an email would be sent to the email address to confirm it is them and then they could generate just a password to allow them to log in with information already stored.
I could they link other data on the website to the userid I have stored for them throughout the entire process.
So my query would be whether this is the correct way to go about this?
How have others used these types of login api's and then binded them to on site data?
I believe this to be a reasonable question but if I have placed it in the wrong section, please feel free to move it!
Thanks.
well, everything should be written here http://developers.facebook.com/ also try using php sdk for facebook api, for twitter here https://dev.twitter.com/
Create an app in both fb and twitter, take the access token and access token secret
You should download all the files necessary and then configure them as is written in manual, if you will have trouble connecting to them write me a message to my mail(jurijs.nesterovs#inbox.lv) i'll try to help
Have done that before myself for my site. It was Fb/Twitter/Google. I bet thats the best thing to do. Google's API is the easiest out of these 3. Twitter was hard for me since I dont use OOP and all the libraries out there was OOP.
And about your design, my site was made not to not allow the user to join with the same email again. If they have joined using Facebook with an email, when they try to join using twitter with the same email, I would tell the user that they are already registered using Facebook.

Take the likes from users of my app and file them into csv

I need to be able to consolidate all the likes from users that use my Facebook app into an Excel or .csv file. I can have the user authenticate within my Facebook app, but is there a way to see the likes for all users of an app using Open Graph or some other Facebook tool? I'm certain that someone else must have had this problem, and I'm hoping that one of you can help me out!
I've been trying to run FQL queries to bring up likes, but don't have any experience with PHP so it has been miserable so far. Any ideas?
There's no way to retrieve a list of users of your app - you'll need to manually build that as users authorise the app see this question for more information
Assuming you have permission to access a user's likes connection - access /USER_ID/likes and parse the response, saving it to a file in accordance with whatever language you're using's syntax (google is your friend here)
Note that your use of the data is subject to Facebook's policies and user's consent in accordance with your privacy policy and sharing it with third parties may be illegal (i am not a lawyer, this is not official advice, etc etc)
Here is the problem with that the application type does not have a like connection. Application Object GraphAPI This is inconvenient when you are looking to gather data on the users that like it.
OR were you talking about the likes endpoint of the user object? That you can gather but I dont think it is what you are looking for. It is shown here Graph Explorer Example - user's likes

Why is the Facebook Access Log showing more than it should?

I'm using the server-side SDK to access Facebook Authentication.
After authorizing my app - even with the included example.php, I can go to App Privacy in settings then click on the app, then See Details in the Last data access section
And the dialog shows:
My App accessed the following information on your behalf:
Basic Information - Today
Likes, Music, TV, Movies, Books, Quotes, About Me, Hometown, Current City, Education History and Work History - Today
My Friends' Current Cities - Today
All I really need from the authentication is the userid and possibly name... I don't care about any other personal info. And yet even the example.php which is really basic seems to be requesting a lot.
Is there another way to authenticate without Facebook thinking I pulled all this data? I don't want users to be concerned about excessive data pulling when I'm not even pulling it.
The Stack Exchange authentication does not have this issue. It might be an issue in the PHP SDK?
The additional entries in the app access log are created for requests to the /me-object without a fields-parameter. So instead of accessing /me?access_token=xxx use /me?fields=id,name,...&access_token=...
Please note that the access log is not deleted when you remove an application. This may be quite confusing during testing because you will see old entries.

Categories