I want to write some PHP code that will allow me to make an HTTP call to a URL (from an external, unrelated program) and have it return a JSON-formatted list of my Patreon supporters (full names only).
Edit: I have gone through the setup for making an app and getting access tokens and all that. Should've clarified.
In general, I'm a beginner to PHP so the setup process for the Patreon API has been confusing. I've never installed external packages to PHP before and the formatting of the examples given in the API Documentation is confusing to me. That, and there seem to be two different versions of the API with the documentation not specifying which is used in its examples.
I first tried the recommended solution of using Composer, and that seemed to have installed the Patreon API, but I didn't know where, and it wasn't plug and play with the code provided in an example from the docs.
So then I downloaded the API manually from their github page, taking the PHP files from the src folder and having my code refer to them with include.
I thought I had the API working, but it looks like certain functions aren't working as intended.
Uncaught Error: Call to a member function get() on array
This was after my attempt to implement the aforementioned example. The fetch_campaign() function seems to not exist in the API.php file, so I replaced it with fetch_campaigns() which I saw does exist in the API.php file. Still, it seems to not have worked.
I thought this could be a quick and easy thing I could knock out in the morning before work, but as per usual it's far more difficult in practice than on paper :P
In any case, I'm simply looking for a way to return a JSON-formatted list of Patron names through PHP, and perhaps also some guidance on getting the API to work in the first place.
Related
I am learning to use websockets with the PHP framework Ratchet, and I am wondering if there is other fields that we can use inside the "$conn" argument that we get to see in many of the methods (such as "onOpen" or "onMessage" where it is called "$from").
I have already seen people online use ->resourceId or ->remoteAddress, and when I "var_dump" it I can clearly see that there is much more attributes about the request inside (but it appears all unfolded in my console so I cant really read anything).
So I searched on the internet for some kind of documentation, but cant find anything !
Those burried informations seems very important to me, since you could deny some client that would connect but doesnt match a certain profile (that we would previously and preciesly determined) ...
Is there any skilled PHP and Ratchet developper out there that would know how or where to get a list of all those fields ?
I tried var_dumping the "$conn" object, but as it outputs unfolded in my prompt, I cant analyse the structure of it.
I thought I could find some kind of documentation on the internet but after a long long search I gave up ! This is strange because I value those fields : they seem very practical to me so I don't understand why I didn't find any documentation
I came across this cool little PHP function testing tool website today at http://php.fnlist.com/array/array_count_values
It claims to have over 200 PHP functions to test online.
Each functions has a page which has input fields for each function parameter. You can then enter a string, array, date, or whatever is ask for and it will pass those input field values into the PHP function and show the result on the page.
It's a useful little tool for testing how certain functions work on different sets of data, etc...
I am building a Web Developer Toolbox app which takes all my most used and favorite web dev apps and tools and combines them into 1 single app. Each tool in my app is going to be a "plugin" so that users can add/disable/create there own dev tools as needed in the app.
So I am wanting to have a plugin tool in my app with similar functionality as this website to allow the testing of PHP functions.
Does any open source projects exist that do this task already that anyone knows of? Otherwise I am asking how to go about building such a tool.
For example if a function parameter expects an array to be passed in. How can I ensure that the text input POSTed has a valid array or string or Date or whatever it is asking for?
Also any other related info that might be useful to build such a tool is appreciated
I found a solution here https://github.com/Corveda/PHPSandbox
Demo of it: https://code.phpsandbox.org/
GitHub project: https://github.com/Corveda/PHPSandbox
Docs: https://manual.phpsandbox.org/2.0/
I am new to android and php and working on old project.
Everything worked smoothly till yesterday. I am getting all videos from you tube api:
https://gdata.youtube.com/feeds/api/videos?q=&start-index=1&max-results=10&v=2&alt=json
But from today, i just get only one video from this link and that is:
https://support.google.com/youtube/answer/6098135?p=yt_devicesupport&hl=en&rd=1
I have read that v2 become depreciated so i need to move to v3 version ?
I need help on how to get all videos as before.
There isn't really an easy answer for this. At least, we can't really just give you a new address to plop in the place of the old one. API v3 is structured differently and has different requirements than v2. Some of those changes at least theoretically bring some performance advantages, but when requesting things from this new API, you need to be more specific about what you're looking for. Also, since some of the data has moved around within the JSON results, you may need to change where your code looks for given information.
As it is, I don't really know what information you need, or for that matter, what collection of videos you're looking for. In this version of the API, these details actually matter. In v3, you have to provide a comma-separated list of the information you're looking for, and then at least one more "filter" parameter as well (filters, for your cases are probably either "chart" which is something like the "chart of the most popular", or "id" which is a comma-separated list of video IDs.)
While it's probably not the answer you were looking for, you probably need to stroll through the documentation. I especially suggest the Try It section, where you can plug in your parameters and build the query.
You'll need an API key to use the new API, and you can get that key from the Google Developers console. Create a new project, and add the YouTube API to it.
I am new to CakePHP, my first framework. I've been doing some of the basic tutorials provided in the documentation, and I often come across a method or an attribute that I want to know more about. For example:
//App/Model/User.php
...
public function isOwnedBy($post, $user) {}
My question is, how do I find more details about any attribute or method? I've tried searching using the internal search but no results. I've also been googling in the hope that that might give me results, but nope. I've tried using the API to look it up, but no results either. Am I doing something wrong?
Understanding what exactly a method does, and an attribute is, makes it much easier to follow the tutorials in my own experience. Especially in the Authentication/Authorization stage, where lots of methods and attributes get introduced without too much explanation.
If it's part of the core API, then it's documented in the API docs. Parts of the API are also described in detail in the CookBook. To get a more detailed grasp on what's going on you can of course always have a look at the source code.
That specific method however is a custom model method from the CookBooks Simple Authentication and Authorization Application example, so you won't find anything about it in the API documentation as it's not part of the core API.
In case the code provided in the examples isn't documented well enough for you to understand it, then you can always ask for further explanation/help, for example in the groups, the chat, etc (see http://community.cakephp.org/), and also here on Stack Overflow if you have a specific questions.
I'm developing an iPhone APP and need to implement also an Web Service.
First of all I'm not a Developer and never made something big in PHP, Objective-C, xCode.
My PHP knowledge isn't also good. But let's start with my Environment.
iPhone APP (xCode 4.2, iOS5), PHP Web Service, MySQL DB
I was researching the WEB and most People tend more to REST than SOAP. I think i see also the advantages of REST (using of simple HTTP Verbs (get, post, delete etc...), but that's not the main point here...
I think I understand the main goal of the REST Architecture and tried to make a little concept with an URI and Verb Mapping. Here just a simple example of the mapping:
/location/{location_id}/product
/location/{location_id}/product/{product_id}
Both are GET operations who should get me ether a single product or all products of a location.
How would a simple PHP REST Web Server look like with these functions?
Another part should implement a User Authentication from the iPhone. Somehow i need to store the user session, right now I don't have any idea how to make that. The goald is that if only a user is logged in, he could review the product.
Now I've researched also the Web but couldn't find an easy step-by-step Tutorial.
Do you know any good Tutorials which will help me achieve my goal? :)
A lot of people prefer using PHP Frameworks like ZEND. This seems very interesting, but it seems like a big package with a lot of modules.
Does someone know exactly which Modules are needed to get my Web Service working?
This is quite a good tutorial, it uses the codeigniter framework which makes the learning curve a bit steeper but makes it a lot more powerful in the long run.
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
If you want to build this the custom way it's actually very easy to do if you want to return information in the JSON format especially for php5 which is generally well supported amongst hosts these days.
Essentially the steps are like this:
Pass in product id via url and retrieve using GET i.e. service.php?product_id=10
Query database and return data for product id that was passed in
Store returned data in an array
Set header content-type to application/json
json_encode the result (json_encode)
That way when you call that url in a browser you will get a nice JSON formatted array result in a key:value pair manner. And as of iOS5 json parser comes with the framework (for earlier versions SBJson is a good framework to use (SB JSON))