Solved

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

Posted on 2014-03-21
5
735 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39947380
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
ID: 39947802
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 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39947941
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
ID: 39957744
thanks!
0
 
LVL 110

Expert Comment

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

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

737 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