Solved

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

Posted on 2014-03-21
5
741 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Make the most of your online learning experience.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project

717 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