Getting Operation statistics of CSGO using steam web api - php

I want to fetch all Operations' statistics of Counter-Strike: Global Offensive for any user by his/her steam64 ID. I have found an api request url which returns a list of achievements for this user by app id.
http://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001/?appid=730&key=<<API KEY>>&steamid=<<STEAM64 ID>>
But it doesn't return any operation's statistics as far as i see. Experts, please help me to fetch all Operations' statistics of CSGO.

Achievements and operations are completly different things:
Achievements - Virtual badges you get during the game, for every game, triggered by the game itself
Operations - Paid set of missions (...), only in CS:GO, triggered by whether you got the operation or not
You can check if somebody took part in an operation by looking in his inventory (there should be a coin/ medal to identify) but the individual stats arenĀ“t accessible by the Web API.
If you still figure out a way to achieve this, please post this here.

Related

Best way to save user view counts for advertisements in PHP & REST API

I have a REST API built with PHP & MySQL for storing ads.
My database contains an ads table and a users table.
I want to bump the view count for every ad once a user is viewing it (only once, if he views it for the 2nd time, I don't want to raise the count again).
Also, how do I go about setting up a service for the client? Psychologically it seems very aggressive to make a server request each time a user is watching an ad, it could get to hundreds of requests at the same time.
Thanks! :)

Twitter API Rate Limit for Multiple Users

I am writing a PHP-based application using the Twitter API. Up until now I've been using the REST API via a GET request on a PHP page. However, as my app scales, I can easily see it going over the 150 requests-per-hour limit. Here's why:
I have categories of topics, each which periodically poll the Twitter API for tweets around a topic. For example, I have: mysite.com/cars, mysite.com/trucks, etc. A user can go to either page. When he is on the page, live, refreshing updates are pulled from Twitter by making an AJAX call to a PHP page I've set up. The PHP page determines which category the user is coming from (cars, trucks), polls Twitter for search results, then returns the JSON to the category page. This sounds confusing, but there are a number of unrelated reasons I need to have the intermediate PHP page.
The problem is that since the PHP page is making the requests, it will eat up the rate limit very quickly (imagine if there were 20 categories instead of just cars and trucks). I can't make a single call with multiple parameters because it would combine multiple categories of tweets and I'd have no way to separate them. I can cache results, but if I did, the more categories I add, the longer each would have to go between API calls.
So how can I approach this problem? I looked at the streaming API, but it's only for oAuth'd users and I don't want my users to have to log in to anything. Can I use the stream on the PHP page and then just make continuous requests each time the category page polls the PHP page? Thanks for any help!
a) You don't have to use your websites user's oAuth credentials in streaming API - just your's:
get them somewhere in dev.twitter.com and hardcode them. Your users won't know there is any oAuth going on backstage.
b) Don't use anonymous requests (150 per IP per hour) use oAuth requests (350 per oAuth per hour). You don't have to ask your users to sing in - just sign in few (1 is sufficient for start) your private twitter accounts. If you don't like creating twitter login functionality, you can get credentials for your twitter account to your twitter application in dev.twitter.com .
c) As #Cheeso mentioned - cache! Don't let every pageload make twitter request.

Need suggestions about a Facebook analytics system

I'm working on a small project which will basically do some Facebook stuff and pulls the new daily like for client's pages into my database so I could show them my own charts with their page statistics. Now first of all, I have made a cURL request running with a cron-job and scraping their Total Likes every day using the simple graph-api URL.
The problem is with New Daily Likes / Daily unlikes because, based on my little research, there is no way to access these without having a valid access_token and doing today total - yesterday total is not exactly correct, because it will confuse the new likes with the people who disliked this and it will be a total mess.
I don't want to force my clients to go to Facebook and get an access token to access the insights for 2 reasons: 1) I want it to be totally non-technical so they will not need to mess too much with tokens and stuff outside of my panel. 2) I bet some of them will have problems with storing their access tokens in my database.
How do I do that so they will only need to give me the ID of their page (that's how it currently works and I don't want to change it)?
Basically, there are 2 ways to get Likes information, one is to query public information, like:
http://graph.facebook.com/cocacola
And the other one is to query for page insights information, for which you need access tokens with right permissions.
If you don't want your clients to install your Facebook application with permissions (and with that, give you access token), your only option is to query public information.
As you've noticed, that gives you a problem, since each day "likes" gain is "mashed up" from users adding likes and removing likes, and thus, you dont have precise information about how many users liked and disliked every day. One way would be to query the information, lets say per hour, or even 5 minutes, and store that information. Then, by simple math, you can see how many users liked and disliked the page. It is still not totaly precise, but its alot more valid than "daily information".

Facebook OAuth Error: Application request limit reached

I'm trying to get facebook's example page working (again) which you can find here. I'm getting the following error:
Fatal error: Uncaught OAuthException: (#4) Application request limit reached thrown in C:\wamp\www\base_facebook.php on line 988
I've googled this and the problem seems to be easily fixed by using the steps outlined here. However, when I go to facebook.com/insights, my application isn't listed (I am logged in).
The weirder part is that when I go to my app via Developers > My apps, I can go to the page of my app and click "Insights". This brings me to the Insights page for my app... but the diagnostic section is nowhere to be found. Can anyone help?
The outlined way of finding out why this happens is:
Log into https://developers.facebook.com/apps/
The last app you've edited should already be loaded on the right side; if not, find your app on the left side and click the name.
Scroll down until you see the Insights section and click See All.
From the menu on the left side, select API > Activity & Errors.
The Facebook "Graph API Rate Limiting" docs says that an error with code #4 is an app level rate limit, which is different than user level rate limits. Although it doesn't give any exact numbers, it describes their app level rate-limit as:
This rate limiting is applied globally at the app level. Ads api calls are excluded.
Rate limiting happens real time on sliding window for past one hour.
Stats is collected for number of calls and queries made, cpu time spent, memory used for each app.
There is a limit for each resource multiplied by monthly active users of a given app.
When the app uses more than its allowed resources the error is thrown.
Error, Code: 4, Message: Application request limit reached
The docs also give recommendations for avoiding the rate limits. For app level limits, they are:
Recommendations:
Verify the error code (4) to confirm the throttling type.
Do not make burst of calls, spread out the calls throughout the day.
Do smart fetching of data (important data, non duplicated data, etc).
Real-time insights, make sure API calls are structured in a way that you can read insights for as many as Page posts as possible, with minimum number of requests.
Don't fetch users feed twice (in the case that two App users have a specific friend in common)
Don't fetch all user's friends feed in a row if the number of friends is more than 250. Separate the fetches over different days. As an option, fetch first the app user's news feed (me/home) in order to detect which friends are more important to the App user. Then, fetch those friends feeds first.
Consider to limit/filter the requests by using the following parameters: "since", "until", "limit"
For page related calls use realtime updates to subscribe to changes in data.
Field expansion allows ton "join" multiple graph queries into a single call.
Etags to check if the data querying has changed since the last check.
For page management developers who does not have massive user base, have the admins of the page to accept the app to increase the number of users.
Finally, the docs give the following informational tips:
Batching calls will not reduce the number of api calls.
Making parallel calls will not reduce the number of api calls.
If you make a GET request to one of FB graph API endpoints that does not require access_token that does not mean you should not include it in request parameter. If you do as FB documentation says as do not include access_token than in FB server side it registers into your server machine. So limit (whatever amount is it exactly) can be reached very easily. If you however, put the user access token into the request (&access_token=XXXXXX) then requests register into the specific user, so the limit hardly ever be reached. You can test it with a simple script that makes 1000 requests with and without user access_token.
NOTE, FB app access token will not be sufficient as you will face the same problem: requests will be registered into app access_token that situation is alike making requests without access_token.

Game Lobby in PHP/MySQL

I'm creating a mobile game on various mobile platforms and have decided to use PHP/MySQL as the back end and communicate with this via JSON. (The game will be text based).
I'm lacking on idea's on how to implement this, the sort of logic i'm after is as follows;
User will need to register an account
User will enter the game lobby looking for an open slot
If there is a suitable game ready and waiting (not full and waiting for new players) then join
If not create a new game and await players
I was thinking of having 20 players for each game and only allowing the game to start when there's 3 or more players waiting. When there's 3 or more players waiting there would be a count down of say 60 seconds until the game began.
Now i know some of this might need to be done on the client side. I'm struggling on where to start!! So any idea's, code samples or links to reading material that may help would be very much appreciated.
thanks!
Based on comments, I'm guessing you're looking for some ideas on database schema, like Brad Christie suggests. So I'm going to start with that.
First, you'll need a table for the players. I'm guessing you already have one of those, but you'll probably want to include a field for the game ID that they're in.
Next, you'll need a table for the games. This is where you store information on the game itself, including whether it's active. To get the player count, you simply query the list of players with that game's ID. You could also keep track of player count and update it whenever the player leaves or joins the game, depending on a few factors.
Now, the game lobby itself. The exact method here really depends on how you want it to function. You can either use AJAX to keep a list of currently active games up to date (and set up some sort of chat system to let players talk while waiting), or you can use the game lobby as routing page. If you go the latter route, then query the active games, automatically dump the player into one that meets your criteria, then send the user to the 'main game page'.
Hopefully this will give you a solid outline on how to start. I'm afraid I can't help you much more unless I know more about your requirements.
For register a user you simply need a form and save that form in your database. When the user logs in the you query the database matching the password and user name.

Categories