Entries Tagged as 'PHP'

Posting to application wall from application

There are a lot of examples how to get user permission to write on his wall, and how to obtain access token for writing to wall of pages owned by some user. But how about writeing to application wall, from that application? Access token for this wall is not between access tokens you get with geting “manage_pages” rights.

But it is simple. You just go to:

https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=<APP_ID>&client_secret=<APP_SECRET>

and you will get access token, which can be used for posting on application wall.

Thank you – Sergiy Kovalchuk for this.

PHP code can look like this:

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://graph.facebook.com/$appid/feed");
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch,CURLOPT_POST,true);
$post = array("access_token" => $access_token);
$post["message"] = $message;
curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$ret = json_decode(curl_exec($ch));
curl_close($ch);

Of course, additional field, link etc… can be added. More can be found on facebook documentation which covers 95% of unneeded features and 5% of needed :-))

Ena PHPjasta

1. Ali je dodajanje na konec stringa hitrejše kot dodajanje na začetek?

$out .= $str; vs $out = $str.$out;

2. Ali je $out .= $str; različno od $out = $out . $str;

3. Ali se bolj splača $out .= $str; ali $out[] = $str? (in na koncu implode)

Si upa kdo ugibati?

WordPress image resize

Pred dnevi me je presenetil klic mojega server providerja, ki je opazil da mu kurim daleč največ bandwidtha naokoli. Šlo je za okoli 150GB mesečno, pri čemer imam promet neomejen. Saj, če to preračunamo na enakomeren prenost, to sploh ni tako veliko, ampak očitno precej odstopa od ostalih in mu je padlo v oči. Šel sem preverit kaj ustvarja takšen promet in nič ni kazalo na kakšno zlorabo, morebitni vdor na strežnik ali kaj podobnega. Podatek je tudi mene malce presenetil, ker nekako ne pričakujem, da bi moj blog bralo pol Slovenije (ali pač?).

Šlo je enostavno zato, da sam vedno uplodam fotke takšne, kot pač pridejo iz fotoaparata, to pa je po par MB. In potem imam ob strani en image rotator, ki vsakih par sekund potegne novo fotko dol. Recimo 5 na minuto. Pa imamo 15 MB v minutki. In če en post bereš malce dlje, pa smo pokurili 100 MB. Kar seveda ob današnjih hitrostih sploh ne opaziš. Sem pa opazil sam na morju, kjer sem pri objavi in pregledu posta lepo pokuril 100 kun prometa.

[Read more →]

WordPress media uploader freezes at “crunching”

After transfering sites to another server (TUS hosting does not offer rent-a-host anymore, they still have offer on web page, but via email they request to release server) image upload become unusable. Image was uplaoded, then wordpress stops. Nothing. Images was uploaded but cannot continue with inserting them into post. Just like in this thread.

After adding folowing files to .htaccess file everything works ok now.

php_value max_execution_time 600
php_value memory_limit 256M

Site transfers are in most cases painful operation. One down, how many to go?