我有以下代码:
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=> "x-api-key: hidden"
)
);
$context = stream_context_create($opts);
$fp = fopen('https://mercury.postlight.com/parser?url=https://www.dev-metal.com/architecture-stackoverflow/', 'r', false, $context);
fpassthru($fp);
fclose($fp);
输出以下内容:
{"title":"The architecture of StackOverflow","author":null,"date_published":"2014-01-11T11:54:47.000Z","dek":null,"lead_image_url":"https://www.dev-metal.com/wp-content/uploads/2014/01/stackoverflow3.jpg","content":"
One of the most interesting talks these weeks, and a rare insight into one of the most active pages on the web: Marco Cecconi of StackOverflow speaks about the general server architecture, why they don’t unit-test (!), how they release (5 times a day) and shows some awesome server load screenshots. It’s fascinating that they run one of the most trafficked pages (that also uses long-polling “real-time” messaging !) on just 25 servers, most of them on 10% load all the time. “We could run it on just 5 servers if needed”. Awesome. Nice statements regarding caching and using existing code, too.
I really like the Get-Things-Done attitude and the simple, but productive view on workflow (use multiple monitors, don’t be the nerd sitting in front of a laptop). The code is not perfect (lots of static methods), they don’t even test, only have a hand full of developers (!) and nearly no downtime. Ah yes, and they run one of the most successful sites in the history of the internet.
“Languages are just tools”. “You’ll be successful anyways, or fail anyways [it does not depend on the language].” I really like that guy. And by the way, they mainly use dot.net for the site. Make sure you also check out the links, especially #5 shows the current tech stack used in the company.
And by the way, have you noticed that EXTREMELY huge presentation screen ? Awesome! They obviously did this in a cinema or university audimax.
Update #1: The slides of this talk:
https://speakerdeck.com/sklivvz/the-architecture-of-stackoverflow-developer-conference-2013
","next_page_url":null,"url":"https://www.dev-metal.com/architecture-stackoverflow/","domain":"www.dev-metal.com","excerpt":"One of the most interesting talks these weeks, and a rare insight into one of the most active pages on the web: Marco Cecconi of StackOverflow speaks about the general server architecture, why they…","word_count":256,"direction":"ltr","total_pages":1,"rendered_pages":1}
我的问题是我似乎无法将数组输出到我可以操作它的位置。我尝试使用extract()
并使用foreach()
输出,但其行为类似于字符串。但令我难过的是我只能var_dump()
输出的事实。如果有人知道我做错了什么,请告诉我。只有我能想到的修复是,如果输出只是一个字符串,有没有办法将它变回一个数组?
答案 0 :(得分:2)
您应该从文件中读取内容,然后转换为json
$fp = fopen('https://mercury.postlight.com/parser?url=https://www.dev-metal.com/architecture-stackoverflow/', 'r', false, $context);
$contents = stream_get_contents($fp);
$output = json_decode($contents, true);
print_r($output);
参考:fread检查示例#3远程fread()示例
答案 1 :(得分:1)
尝试使用此功能;
-ms
答案 2 :(得分:0)
请尝试以下代码:
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=> "x-api-key: hidden"
)
);
$context = stream_context_create($opts);
$fp = fopen('https://mercury.postlight.com/parser?url=https://www.dev-metal.com/architecture-stackoverflow/', 'r', false, $context);
$output = json_decode($fp, true);
print_r($output);
fclose($fp);
...谢谢
答案 3 :(得分:0)
试试这个
PATCH https://www.onenote.com/api/v1.0/me/notes/pages/{page-id}/content