Solved

Can you review my API calls and tell me if this is a good strategy?

Posted on 2014-03-21
5
705 Views
Last Modified: 2014-03-27
Hello,

I am planning on doing some API calls to get some share counts for a set of URLs. I found this bit of code on the interwebs, but I'm not sure if it's a great strategy. Would one of you experts take a look and tell me for each:

1. Is this an API call that has been deprecated?
2. Is there a rate limit on this call and would you know how to find it?
3. Is there a better way to get this info?

I realize I can look this up myself in the API docs for each provider, but it's confusing to a newb like myself and I just don't seem to understand.

Thanks for the help!

http://graph.facebook.com/http://nerdist.com
https://cdn.api.twitter.com/1/urls/count.json?url=http://nerdist.com
http://api.pinterest.com/v1/urls/count.json?callback=&url=http://nerdist.com
http://www.linkedin.com/countserv/count/share?url=http://nerdist.com&format=json

Open in new window

0
Comment
Question by:EffinGood
  • 3
  • 2
5 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Facebook, LinkedIn and Twitter seem to return useful information, but we don't know what you're looking for.  

Pinterest returns this JSON string (assume you already tested and saw the failure, right?):

{"error": "Invalid callback, use only letters, numbers, square brackets, underscores, and periods."}

Setting aside the technical questions about APIs, can you just tell us in plain language what's the business goal here?
0
 

Author Comment

by:EffinGood
Comment Utility
Hi Ray,

I am just wanting to get the shared counts of a given url. Sorry, yes, I saw the failure from Pinterest and fixed my call.

I just want to know if I'm calling those APIs in a way that is OK with the provider.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
It looks OK to me.  Since these are GET method requests without any API key requirements, I would assume that you're OK.

You can use JSON_Decode() to turn the string responses into objects, then you can access the data with object-oriented notation.  Example here:
http://iconoun.com/demo/temp_effingood.php

<?php // demo/temp_effingood.php
error_reporting(E_ALL);
$url = 'https://cdn.api.twitter.com/1/urls/count.json?url=http://nerdist.com';
$jso = file_get_contents($url);
$obj = json_decode($jso);
echo $obj->count;

Open in new window

HTH, ~Ray
0
 

Author Closing Comment

by:EffinGood
Comment Utility
thanks!
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points and best of luck with the project, ~Ray
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now