Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9292323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:51:04+00:00 2026-06-18T20:51:04+00:00

I’m trying to get the json data from the following url: https://chart.googleapis.com/chart?cht=gv&chl=digraph framework {

  • 0

I’m trying to get the json data from the following url:

https://chart.googleapis.com/chart?cht=gv&chl=digraph framework { 1[color=red]; 2; 3[color=red]; 4; 5; 6; 7; 8; 9; 10; 11; 12[color=red]; 13; 14[color=red]; 15; 16[color=red]; 17[color=red]; 2 -> 1; 3 -> 1; 4 -> 1; 5 -> 1; 6 -> 2; 8 -> 9; 9 -> 8; 12 -> 2; 12 -> 3; 12 -> 4; 12 -> 5; 7 -> 6; 7 -> 10; 7 -> 11; 8 -> 7; 13 -> 5; 14 -> 13; 15 -> 6; 16 -> 15; 17 -> 12; 10 -> 4; 11 -> 3; 14 -> 16; 16 -> 17; }&chof=json

I have tried several methods that were suggested in other questions:

$jsonurl = "https://chart.googleapis.com/chart?cht=gv&chl=digraph framework { 1[color=red]; 2; 3[color=red]; 4; 5; 6; 7; 8; 9; 10; 11; 12[color=red]; 13; 14[color=red]; 15; 16[color=red]; 17[color=red]; 2 -> 1; 3 -> 1; 4 -> 1; 5 -> 1; 6 -> 2; 8 -> 9; 9 -> 8; 12 -> 2; 12 -> 3; 12 -> 4; 12 -> 5; 7 -> 6; 7 -> 10; 7 -> 11; 8 -> 7; 13 -> 5; 14 -> 13; 15 -> 6; 16 -> 15; 17 -> 12; 10 -> 4; 11 -> 3; 14 -> 16; 16 -> 17; }&chof=json"

//Method 1
$json = file_get_contents($jsonurl); 
// returns an error from the google page: 400. That’s an error. Your client has issued a malformed or illegal request. That’s all we know

//Method 2
$curlSession = curl_init();
 curl_setopt($curlSession, CURLOPT_URL, $jsonurl);
 curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
 curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);

 $json_decoded = json_decode(curl_exec($curlSession));
 curl_close($curlSession);
 // returns NULL
 // This makes sense if the JSON isn't not returned correctly. I think json_decode() returns NULL if the input is not correct json data.

 //Method 3
 $json = file_get_contents(urlencode($jsonurl));
 // Gives another error: [function.file-get-contents]: failed to open stream: File name too long

If I just post the raw JSON data in my code the rest of my algorithm works fine. The point is, in my actual code the url is dynamic and I need to be able to get the JSON data from the url.

It seems like an security issue with google. However, I don’t have a clue as of how to solve this.

This is my first question on Stackoverflow. Please let me know if you want to know more/if I should edit my question somehow.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:51:06+00:00Added an answer on June 18, 2026 at 8:51 pm

    Your URL needs to be URI-escaped for cURL to use it properly. If I change your script to this:

    # note that in this string, all special characters (eg. spaces) are %-escaped
    $jsonurl = "https://chart.googleapis.com/chart?cht=gv&chl=digraph%20framework%20{%201[color=red];%202;%203[color=red];%204;%205;%206;%207;%208;%209;%2010;%2011;%2012[color=red];%2013;%2014[color=red];%2015;%2016[color=red];%2017[color=red];%202%20-%3E%201;%203%20-%3E%201;%204%20-%3E%201;%205%20-%3E%201;%206%20-%3E%202;%208%20-%3E%209;%209%20-%3E%208;%2012%20-%3E%202;%2012%20-%3E%203;%2012%20-%3E%204;%2012%20-%3E%205;%207%20-%3E%206;%207%20-%3E%2010;%207%20-%3E%2011;%208%20-%3E%207;%2013%20-%3E%205;%2014%20-%3E%2013;%2015%20-%3E%206;%2016%20-%3E%2015;%2017%20-%3E%2012;%2010%20-%3E%204;%2011%20-%3E%203;%2014%20-%3E%2016;%2016%20-%3E%2017;%20}&chof=json";
    
    # your settings here are fine
    $curlSession = curl_init();
    curl_setopt($curlSession, CURLOPT_URL, $jsonurl);
    curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
    
    # XXX: not entirely safe here
    # curl_exec() could dump out something other than JSON if it encounters an error
    # I recommend saving the output of curl_exec($c) separately in case of error
    $json = json_decode(curl_exec($c));
    

    Then $json contains the data object I would expect. I tested this in PHP 5.3.15 on a Mac.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using jsonparser to parse data and images obtained from json response. When
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.