Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-03-21
5
Medium Priority
?
767 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 111

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 111

Accepted Solution

by:
Ray Paseur earned 2000 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 111

Expert Comment

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

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Make the most of your online learning experience.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Progress
Suggested Courses

609 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