function friendshipCreate($param) { $url = $param['api_end_point'] . '/friendships/create.json'; $user_id = $param['params']['user_id']; $requestMethod = 'POST'; $postFields = array("user_id" => $user_id, 'follow' => true); $twitter = new TwitterAPIExchange($param['settings']); $response = $twitter->buildOauth($url, $requestMethod)->setPostfields($postFields)->performRequest(); //save to db if (!array_key_exists("errors", json_decode($response))) { $current_user = json_decode($_SESSION['current_user'], true); $source_id = $current_user['id']; $target_id = $user_id; $model = new Model(); $model->saveFollowing($source_id, $target_id); } return $response; }