我试图使用Graph搜索API获取结果,并且我注意到在我的计算机(阿根廷)中执行的结果与在服务器(法国)中运行时的结果不同.
这是这样的吗?如何强制搜索位置?
我想用php curl用oauth从中获取JSON数据twitter.这是我的代码.返回na错误消息"error":"Timestamp out of bounds".
我想知道,如何用oauth做一个正确的推特api卷曲?
是什么oauth_consumer_key,oauth_token,oauth_nonce,oauth_signature?我对吗?
怎么解决"error":"Timestamp out of bounds"?
我的curl_setopt方法怎么样?
在很多方面,我想用它php curl来解码其他twitter api(更改的URL).非常感谢.
$callback="<callback url>";
$consumer_key="<Consumer key>";
$consumer_secret="<Consumer secret>";
$oauth_token="<Access Token (oauth_token)>";
$oauth_signature="<Access Token Secret (oauth_token_secret)>";//these key word in my api panel
$time = mktime(date("Y-m-d H:i:s"))-86400;
$url = "https://api.twitter.com/1/friends/ids.json?";
$url .= "user_id=<user id>";
$url .= "&realm=".urlencode($callback)."";
$url .= "&service_provider_id=11";
$url .= "&oauth_consumer_key=".$consumer_key."";
$url .= "&oauth_token=".$oauth_token."";
$url …Run Code Online (Sandbox Code Playgroud) SELECT * FROM dbname WHERE text = 'a%'
(this can get all the `text` fields which begin with the letter "a".)
Run Code Online (Sandbox Code Playgroud)
但是如何获得第一个字母的字段!= [az]?
例如:
\"hello\" // this first letter begin as \ not range in a-z
?? // also first letter not begin range in a-z
...
may also have a white space as the first character.
Run Code Online (Sandbox Code Playgroud)
那么如何使用php mysql查询来获取所有这些结果的第一个字母!=[a-z]?
我有几页.第1页<body id="page1">,第2 页,第<body id="page2">3 页<body id="page3">然后我想在一个css文件'style.css'中写入所有css规则,设置page1背景颜色:#000; page2背景颜色:#fff; page3背景颜色:#00f;
body #page1{background-color:#000;}
body #page2{background-color:#fff;}
body #page3{background-color:#00f;}
Run Code Online (Sandbox Code Playgroud)
但这是错的,怎么写得正确?谢谢.
如何检查文件名是否存在,重命名文件?
例如,1086_002.jpg如果文件存在,我上传图像,将文件重命名为1086_0021.jpg保存,如果1086_0021.jpg存在,则重命名1086_00211.jpg并保存,如果1086_00211.jpg存在,则重命名1086_002111.jpg并保存...
这是我的代码,它只能1086_002.jpg存在,重命名文件1086_0021.jpg,也许应该做一个foreach,但如何?
//$fullpath = 'images/1086_002.jpg';
if(file_exists($fullpath)) {
$newpieces = explode(".", $fullpath);
$frontpath = str_replace('.'.end($newpieces),'',$fullpath);
$newpath = $frontpath.'1.'.end($newpieces);
}
file_put_contents($newpath, file_get_contents($_POST['upload']));
Run Code Online (Sandbox Code Playgroud) <?
$db1 = mysql_connect("localhost","root","root") or dir("can not connect Mysql Server");
mysql_select_db("1",$db1) or dir("Can not connect to the MySQL Server.");
$db2 = mysql_connect("localhost","root","root") or dir("can not connect Mysql Server");
mysql_select_db("2",$db2) or dir("Can not connect to the MySQL Server.");
?>
$result = mysql_query("SELECT * FROM db1.tags WHERE db1.catalog='fresh tag' ");
Run Code Online (Sandbox Code Playgroud)
如果我从多数据库连接,如何从db1进行MySQL查询?
如何用PHP解析Wikipedia XML?我用simplepie尝试过,但我一无所获.这是我想要获取其数据的链接.
http://en.wikipedia.org/w/api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content&format=xml
编辑代码:
<?php
define("EMAIL_ADDRESS", "youlichika@hotmail.com");
$ch = curl_init();
$cv = curl_version();
$user_agent = "curl ${cv['version']} (${cv['host']}) libcurl/${cv['version']} ${cv['ssl_version']} zlib/${cv['libz_version']} <" . EMAIL_ADDRESS . ">";
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_ENCODING, "deflate, gzip, identity");
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_URL, "http://en.wikipedia.org/w/api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content&format=xml");
$xml = curl_exec($ch);
$xml_reader = new XMLReader();
$xml_reader->xml($xml, "UTF-8");
echo $xml->api->query->pages->page->rev;
?>
Run Code Online (Sandbox Code Playgroud) 我尝试使用JSON解码来获取youtube API提要.但是,当我粘贴JSON结果时,http://www.jsonlint.com/我注意到了类似的东西
"media$group": {
"media$category": [
Run Code Online (Sandbox Code Playgroud)
不幸的是,某些符号被php拒绝.这是我的代码,我试图删除这个$符号,但可能没有成功.我该如何解决这个问题?
$url = 'http://gdata.youtube.com/feeds/api/videosq=football&orderby=published&v=2&alt=json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $url);
$body1 = curl_exec($ch);
$body = str_replace('$','', $body1);
curl_close($ch);
$data = json_decode($body);
foreach ($data->feed->entry as $result) {
...
}
Run Code Online (Sandbox Code Playgroud) 我怎样才能获得所有的<img>s width >= 300?
我的标记/代码:
$images = <<<END
<img src="/data/img/201108031_023" width="300" height="400" />
<img src="/data/img/201108031_026" width="250" height="300" />
<img src="/data/img/201108031_028" width="400" height="300" />
<img src="/data/img/201108031_032" width="500" height="400" />
...
END;
Run Code Online (Sandbox Code Playgroud)
我的尝试:
preg_match_all("/<img(.*?) \/>/",$images,$matches);
print_r($matches);
Run Code Online (Sandbox Code Playgroud) 不确定这是否是堆栈.当我在CSS表达式中使用正则表达式时,它是否符合W3C标准?这适用于所有的网络浏览器吗?
<style type="text/css">
a[class^='link']{color:#ccc;}
</style>
<a class="link-a">link A</a><br />
<a class="link-b">link B</a><br />
<a class="link-c">link C</a><br />
Run Code Online (Sandbox Code Playgroud) php ×7
css ×2
mysql ×2
regex ×2
background ×1
curl ×1
database ×1
facebook ×1
file-exists ×1
geolocation ×1
html-parsing ×1
json ×1
mediawiki ×1
twitter ×1
w3c ×1
xml ×1