Skip to content

Instantly share code, notes, and snippets.

View niraj-shah's full-sized avatar
🏠
Working from home

Niraj Shah niraj-shah

🏠
Working from home
View GitHub Profile
@niraj-shah
niraj-shah / tweet_tracking.html
Last active December 20, 2015 19:49
Tracking tweets using Web Intents and the Twitter API
<!-- Include the twitter JS library -->
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
<!-- Tweet button with just text -->
<p><a href="https://twitter.com/intent/tweet?text=My first tweet using Web Intents">Tweet</a></p>
<!-- Tweet button with link and text -->
<p><a href="https://twitter.com/intent/tweet?url=http://www.webniraj.com/2013/08/08/twitter-api-tracking-tweets-using-web-intents/&text=Tracking tweets using Web Intents:"><img src="https://dev.twitter.com/sites/default/files/images_documentation/bird_blue_48.png" /></a></p>
<script type="text/javascript">
@niraj-shah
niraj-shah / chrome_console_log.js
Created August 9, 2013 11:00
Display colourful log messages in the Chrome JavaScript Console
if (typeof console == "object") {
if ( navigator.userAgent.indexOf('Chrome') != -1 ) {
console.log("%cHey! What are you looking under here for? https://www.webniraj.com/", "color: #0677c8; font-size: 18px; font-family: 'Helvetica-Neue', Helvetica, Arial, sans-serif;");
} else {
console.log("Hey! What are you looking under here for? https://www.webniraj.com/");
}
}
@niraj-shah
niraj-shah / fb_accounts_api_call.json
Created August 13, 2013 09:24
What the Graph API returns when calling /me/accounts providing that manage_pages permission has been accepted.
{
"data": [
{
"name": "Your Page",
"access_token": "AAAAABBBBBBBBBBCCCCCCCCCCCDDDDDDDDDEEEEEEEEEFFFFFFGGGGGGHHHHHHIIIIIIJJJJJJJJKKKKKKKKLLLLLLLLL",
"category": "Website",
"id": "01234567890",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
@niraj-shah
niraj-shah / fb_page_share
Created August 13, 2013 09:26
Posting to a page using the page access_token
POST https://graph.facebook.com/[page_id]/feed?access_token=[page_access_token]
&name=Facebook API: Posting As A Page
&link=https://www.webniraj.com/2012/08/09/facebook-api-posting-as-a-page/
&caption=The Facebook API lets you post to Pages you own automatically - either as real-time updates or in the case that you want to schedule posts.
&message=Check out my new blog post!
@niraj-shah
niraj-shah / fb_page_share_success.json
Created August 13, 2013 09:27
On successful posting to page via Graph API, Facebook return this result
{
"id": "01234567890_001122334455667788"
}
@niraj-shah
niraj-shah / share_error_msg.json
Created August 13, 2013 09:39
Error message when POST /page_id/feed if publish_stream permission not requested
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
@niraj-shah
niraj-shah / parse_php_login.php
Created August 13, 2013 11:57
Logging in a user to Parse with PHP
<?php
require_once( 'parse/parse.php' );
$parse = new parseUser();
$parse->username = 'username';
$parse->password = 'password';
$result = $parse->login();
try {
@niraj-shah
niraj-shah / parse_php_calls.php
Last active December 21, 2015 00:38
Usefull Parse.com PHP Functions
<?php
require_once( 'parse/parse.php' );
// Login to parse
$parseLogin = new parseUser();
$parseLogin->username = 'username';
$parseLogin->password = 'password';
try {
@niraj-shah
niraj-shah / parse_php_hide_sensitive_info.php
Last active December 21, 2015 00:39
Hide sensitive information from the default User class and returns data in json format
<?php
require_once( 'parse/parse.php' );
$parseQuery = new parseQuery('_User');
$result = $parseQuery->find();
foreach ( $result->results as $user ) {
unset( $user->email );
if ( isset( $user->authData->facebook ) ) {
unset( $user->authData->facebook->access_token );
@niraj-shah
niraj-shah / banned_users.php
Created August 13, 2013 16:06
Get banned users from Facebook
<?php
// change these to match your app
$app_id = '1234567890';
$app_secret = 'abcdefghijklmnopqrstuvwxyz';
// init facebook class
$facebook = new Facebook( array( 'appId' => $app_id, 'secret' => $app_secret ) );
// call {app_id}/banned/ using app access_token