• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 785
  • Last Modified:

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

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
EffinGood
Asked:
EffinGood
  • 3
  • 2
1 Solution
 
Ray PaseurCommented:
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
 
EffinGoodAuthor Commented:
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
 
Ray PaseurCommented:
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
 
EffinGoodAuthor Commented:
thanks!
0
 
Ray PaseurCommented:
Thanks for the points and best of luck with the project, ~Ray
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now