Meetup API Client v1.0.0

  • PHP
  • March 29, 2013

I love APIs, but I honestly hate having to deal with signing, auth, and curl inside my controllers or services, which means I end up wrapping all of that into something that provides easy access in my controllers. I also love Meetup.com since it really makes managing User Groups pretty cool, even with some bad UI choices, which is exactly where their API comes in, it allows me to provide a decent interface to their features from my own UG page and do all the communication via API.

I was curious about the Guzzle library and how many people mentioned it would make API wrapper so much simpler, so I decided to put all of those together and write my own wrapper that would have complete support for the API (other wrappers only had read-only).

It was a simple process, I prepared 2 basic clients to deal with the auth options available: key auth and OAuth. This was pretty simple with the use of Plugins and the existing OAuth plugin. Next up I tackled the operation definitions, for which i ended up with a screen scraper that would get me most of the information from the Meetup.com Docs, and tweak it from there.

Once the definitions were done I started testing out my use cases and realized that always having to read the ‘results’ item of the response array was tiresome and led to useless code, so I wrote a few custom responses that allow me to directly iterate or access the data with array access and iterators. This proved to be useful and my use cases became much more simpler on the consumption side.

To this I also added a ‘__call’ method that can call any operation and generated proper phpDoc for each method so that IDE’s can easily provide autocomplete for this.

This is a sample of it in action:

 <?php

$client = MeetupKeyAuthClient::factory(array('key' => 'my-meetup-key'));

// Use our \_\_call method (auto-complete provided) $response = $client->getRSVPs(array('event\_id' => 'the-event-id'));

foreach ($response as $responseItem) { echo $responseItem\['member'\]\['name'\] . PHP\_EOL; } 

This has been very useful for AmsterdamPHP since we use the Meetup API heavily and I hope its also useful to more people using that API, installation is also pretty simple since it supports composer, and a Symfony Bundle is in the works. If you want more details go check out the github repository and its README file. Or check it out on Packagist.

comments powered by Disqus

Related Posts

Projeto "Eu desenvolvo seu plugin para Wordpress!"

Projeto "Eu desenvolvo seu plugin para Wordpress!"

  • March 11, 2009

Atualização! Este projeto não está mais ativo. O serviço de desenvolvimento de plugins não é mais oferecido.

Read More
Utilizando Variáveis definidas pelo usuário no MySQL

Utilizando Variáveis definidas pelo usuário no MySQL

  • September 27, 2006

Que jogue a primeira pedra quem nunca errou na projeção de um banco! Uma vez ou outra em sua carreira você vai se ver frente a frente com um problema como este: uma tabela foi criada, devido ao seu formato e os dados não é necessária a presença de uma chave primária, ou é utilizada uma chave primária composta, abrangendo mais de um campo. Até então tudo ok, mas com novidades e um upgrade do sistema, você percebe a necessidade de criar um campo de auto-increment para ser sua chave primária, no meu caso para facilitar uma interface em AJAX.

E agora? Você tem uma tabela cheia de dados, que devido a Lei de Murphy você não pode apagar. Com isso o MySQL não deixa o campo ser adicionado/alterado como auto-increment e chave primária. Um labirinto e tanto, mas com algumas pesquisas e alguns neurônios fritos achei uma solução para rodear este problema.

ATUALIZAÇÃO: Fui informado de que havia uma falha na minha lógica e usando uma simples query o mesmo resultado pode ser obtido (eu havia tentado porém minha ferramenta de modelagem executava os comandos em ordem diferente por isso tive problemas), portanto vou coloca-la no final do artigo, mas materei este artigo como um bom exemplo de como se pode usar variaveis definidas pelo usuario no MySQL.

Read More
Anti-Spam Images

Anti-Spam Images

  • July 8, 2006

Vamos começar então pelo passado, antes de apresentar meus mais novos projetos vou começar pelo primeiro script ou classe que eu ofereci ao público em geral.

Read More