网站设计

PHP Get 方法加号处理

用 get 方法 , 参数里有 “+” 时,要做处理,否则到后台会变成空格

解决方案:

1 、改用 post 方法 ,ok

2 、在 js 里用 url = encodeURI(encodeURI(XXX))

3 、将参数里的加号进行转换 data = data.replace(/\+/g, “%2B”);
(2,3步可以合为一步 encodeURIComponent(encodeURIComponent(xxxx)) )

4、 PHP接受使用 rawurldecode后台再解码一次, ok


Using OpenGraph with PHP (cUrl requests for actions)

When I press the “get code” link near the action, that’s what I get:
curl -F ‘access_token=***’ \
 -F ‘article=http://example.com’ \
    ‘https://graph.facebook.com/me/yellowheart:read’

(There’s an actual access token of course).
sing the PHP SDK you would use the api method.
$facebook = new Facebook($config);

$facebook->api(‘https://graph.facebook.com/me/yellowheart:read?  
                article=http://example.com”,’POST‘);

You could also do a raw request
$myurl = [...]


facebook Uncaught CurlException

If you’re on windows system you can fix it adding this, define CA path:
CURLOPT_CAINFO => ‘C:\xampp\htdocs\myFacebook\fb_ca_chain_bundle.crt’
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT        => 60,
CURLOPT_USERAGENT      => ‘facebook-php-2.0′,
//CURLOPT_CAINFO => ‘C:\xampp\htdocs\myFacebook\fb_ca_chain_bundle.crt’,
);
If you’re not, try this one:
$opts[CURLOPT_SSL_VERIFYPEER] = false;
$opts[CURLOPT_SSL_VERIFYHOST] = 2;